-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aizu/4023.cpp aizu/4024.cpp aizu/4025.cpp aizu/4026.cpp aizu/4027…
….cpp aizu/4028.cpp aizu/4029.cpp aizu/4030.cpp aizu/4032.cpp
- Loading branch information
Showing
11 changed files
with
907 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
|
||
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ||
|
||
using namespace std; | ||
|
||
int main(void){ | ||
int n; | ||
scanf("%d", &n); | ||
REP(i, 0, 2 * n + 1) { | ||
REP(j, 0, 2 * n + 1) { | ||
printf("%c", i % 2 == 0 && j % 2 == 0 ? '.' : '#'); | ||
} | ||
puts(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <algorithm> | ||
#include <cassert> | ||
#include <cctype> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <deque> | ||
#include <functional> | ||
#include <iomanip> | ||
#include <iostream> | ||
#include <list> | ||
#include <map> | ||
#include <queue> | ||
#include <random> | ||
#include <set> | ||
#include <sstream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ||
#define DEBUGP(val) cerr << #val << "=" << val << "\n" | ||
|
||
using namespace std; | ||
typedef long long int ll; | ||
typedef vector<int> VI; | ||
typedef vector<ll> VL; | ||
typedef pair<int, int> PI; | ||
const ll mod = 1e9 + 7; | ||
|
||
|
||
|
||
int main(void) { | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
string s; | ||
cin >> s; | ||
int ma = 0; | ||
for (char c: s) { | ||
ma = max(ma, c - '0'); | ||
} | ||
ma++; | ||
if (ma == 10 || s.size() == 1) { | ||
cout << "No" << endl; | ||
} else { | ||
cout << "Yes" << endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <algorithm> | ||
#include <cassert> | ||
#include <cctype> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <deque> | ||
#include <functional> | ||
#include <iomanip> | ||
#include <iostream> | ||
#include <list> | ||
#include <map> | ||
#include <queue> | ||
#include <random> | ||
#include <set> | ||
#include <sstream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ||
#define DEBUGP(val) cerr << #val << "=" << val << "\n" | ||
|
||
using namespace std; | ||
typedef long long int ll; | ||
typedef vector<int> VI; | ||
typedef vector<ll> VL; | ||
typedef pair<int, int> PI; | ||
const ll mod = 1e9 + 7; | ||
|
||
|
||
|
||
int main(void) { | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
int n; | ||
cin >> n; | ||
VI a(n), b(n); | ||
REP(i, 0, n) { | ||
cin >> a[i]; | ||
} | ||
REP(i, 0, n) { | ||
cin >> b[i]; | ||
} | ||
vector<PI> ba; | ||
REP(i, 0, n) { | ||
ba.push_back(PI(b[i], a[i])); | ||
} | ||
sort(ba.begin(), ba.end()); | ||
int ans = 0; | ||
REP(i, 0, n) { | ||
if (ba[i].first == ba[i].second) { | ||
continue; | ||
} | ||
bool found = false; | ||
REP(j, i + 1, n) { | ||
if (ba[i].second == ba[j].first) { | ||
found = true; | ||
} | ||
} | ||
if (!found || ba[i].first > ba[i].second) { | ||
cout << -1 << endl; | ||
return 0; | ||
} | ||
ans++; | ||
} | ||
cout << ans << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <algorithm> | ||
#include <cassert> | ||
#include <cctype> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <deque> | ||
#include <functional> | ||
#include <iomanip> | ||
#include <iostream> | ||
#include <list> | ||
#include <map> | ||
#include <queue> | ||
#include <random> | ||
#include <set> | ||
#include <sstream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ||
#define DEBUGP(val) cerr << #val << "=" << val << "\n" | ||
|
||
using namespace std; | ||
typedef long long int ll; | ||
typedef vector<int> VI; | ||
typedef vector<ll> VL; | ||
typedef pair<int, int> PI; | ||
const ll mod = 1e9 + 7; | ||
|
||
|
||
|
||
int main(void) { | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
string s; | ||
cin >> s; | ||
// oo, ox/xo, xx だけ試せば良い。他のパターンでできるならこれでもできる。 | ||
int ma = 0; | ||
// oo, xx | ||
REP(iter, 0, 2) { | ||
char target = "ox"[iter]; | ||
int bl = 0; | ||
int cnt = 0; | ||
for (auto c: s) { | ||
if (c == target) { | ||
cnt++; | ||
} else { | ||
cnt = 0; | ||
} | ||
if (cnt >= 2) { | ||
bl++; | ||
cnt = 0; | ||
} | ||
} | ||
ma = max(ma, bl); | ||
} | ||
// ox/xo | ||
{ | ||
int bl = 0; | ||
int pos = 0; | ||
while (pos < (int)s.size()) { | ||
string cut = s.substr(pos, 2); | ||
if (cut == "ox" || cut == "xo") { | ||
bl++; | ||
pos += 2; | ||
} else { | ||
pos++; | ||
} | ||
} | ||
ma = max(ma, bl); | ||
} | ||
cout << ma << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <algorithm> | ||
#include <cassert> | ||
#include <cctype> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <deque> | ||
#include <functional> | ||
#include <iomanip> | ||
#include <iostream> | ||
#include <list> | ||
#include <map> | ||
#include <queue> | ||
#include <random> | ||
#include <set> | ||
#include <sstream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ||
#define DEBUGP(val) cerr << #val << "=" << val << "\n" | ||
|
||
using namespace std; | ||
typedef long long int ll; | ||
typedef vector<int> VI; | ||
typedef vector<ll> VL; | ||
typedef pair<int, int> PI; | ||
const ll mod = 1e9 + 7; | ||
|
||
int dist(int x, int y) { | ||
return abs(x / 3 - y / 3) + abs(x % 3 - y % 3); | ||
} | ||
|
||
int main(void) { | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
string n; | ||
cin >> n; | ||
int ans = n.size() * 4; | ||
VI p(9); | ||
REP(i, 0, 9) p[i] = i; | ||
vector<VI> freq(9, VI(9, 0)); | ||
REP(i, 0, n.size() - 1) { | ||
int x = n[i] - '1'; | ||
int y = n[i + 1] - '1'; | ||
freq[x][y] += 1; | ||
} | ||
do { | ||
int sum = 0; | ||
REP(i, 0, 9) { | ||
REP(j, 0, 9) sum += dist(p[i], p[j]) * freq[i][j]; | ||
} | ||
sum += dist(p[n[0] - '1'], 0); | ||
ans = min(ans, sum); | ||
} while (next_permutation(p.begin(), p.end())); | ||
cout << ans + n.size() << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <algorithm> | ||
#include <cassert> | ||
#include <cctype> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <deque> | ||
#include <functional> | ||
#include <iomanip> | ||
#include <iostream> | ||
#include <list> | ||
#include <map> | ||
#include <queue> | ||
#include <random> | ||
#include <set> | ||
#include <sstream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) | ||
#define DEBUGP(val) cerr << #val << "=" << val << "\n" | ||
|
||
using namespace std; | ||
typedef long long int ll; | ||
typedef vector<int> VI; | ||
typedef vector<ll> VL; | ||
typedef pair<int, int> PI; | ||
const ll mod = 1e9 + 7; | ||
|
||
|
||
|
||
int main(void) { | ||
ios::sync_with_stdio(false); | ||
cin.tie(0); | ||
|
||
} |
Oops, something went wrong.