Skip to content

Commit

Permalink
Add aizu/4023.cpp aizu/4024.cpp aizu/4025.cpp aizu/4026.cpp aizu/4027…
Browse files Browse the repository at this point in the history
….cpp aizu/4028.cpp aizu/4029.cpp aizu/4030.cpp aizu/4032.cpp
  • Loading branch information
koba-e964 committed Oct 24, 2024
1 parent 030052a commit 67a1fa2
Show file tree
Hide file tree
Showing 11 changed files with 907 additions and 3 deletions.
16 changes: 16 additions & 0 deletions aizu/4023.cpp
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("");
}
}
49 changes: 49 additions & 0 deletions aizu/4024.cpp
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;
}
}
69 changes: 69 additions & 0 deletions aizu/4025.cpp
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;
}
75 changes: 75 additions & 0 deletions aizu/4026.cpp
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;
}
59 changes: 59 additions & 0 deletions aizu/4027.cpp
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;
}
38 changes: 38 additions & 0 deletions aizu/4028.cpp
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);

}
Loading

0 comments on commit 67a1fa2

Please sign in to comment.