收藏[2099]PID[90938720]_标题[雪ノ下]画师[ふれんど]UID[29332579]_acg17.com
Codeforces Round 163
(Rated for Div. 2)
A
按照题意,奇数肯定不行
偶数就不断输出AAB,每次有2个,满足题意
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <bits/stdc++.h> using namespace std; using ll=long long; const int N=1e6+100; ll a[N]; #define rep(i, a, n) for (int i = a; i <= n; i++) #define frep(i, a, n) for (int i = a; i >= ni--) void solve() { int n; cin>>n; if(n&1) { cout<<"NO"<<'\n'; } else { int t=n/2; cout << "YES" << '\n'; rep(i,1,t) { cout<<"AAB"; } cout<<'\n'; } } int main() { int t = 1; cin >> t; while (t--) { solve(); } }
|
B
感觉从尾枚举是最优的
因为尾部大就不需要分
尾部比前面一个小
一定要分
因此从尾部开始枚举
如果前面的数比尾数大并且不满足分的性质(个位数大于等于十位)或者分完依然大,那么就没救了
如果可以,那么把当前的数字赋值为十位数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, a, n) for (int i = a; i <= n; i++) #define frep(i, a, n) for (int i = a; i >= n;i--) const int N=1e4+100; struct { int v; int l,r; bool vis; }a[N]; void solve() { int n; cin>>n; rep(i,1,n) { cin>>a[i].v; if(a[i].v>=10) { a[i].l=a[i].v/10; a[i].r=a[i].v%10; if(a[i].l>a[i].r) { a[i].vis=0; } else { a[i].vis=1; } } } frep(i,n,2) { if(a[i-1].v>a[i].v) { if(a[i-1].vis&&a[i-1].r<=a[i].v) { a[i-1].v=a[i-1].l; } else { cout<<"NO"<<'\n'; return ; } } } cout<<"YES"<<'\n'; } int main() { int t = 1; cin >> t; while (t--) { solve(); } }
|
C
C题的话实际上感觉和之前某场很像
数据挺大
赛后坤佬说可bfs
实际上我不是用bfs做的
观察奇数点才是我们要走的
记录下来
如果旁边有两0就不行
加点特判
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, a, n) for (int i = a; i <= n; i++) #define frep(i, a, n) for (int i = a; i >= ni--) const int N = 1e6; char a[3][N]; int b[3][N]; void solve() { int n; cin >> n; rep(i, 1, 2) { rep(j, 1, n) { cin >> a[i][j]; } } n /= 2; rep(i, 1, 2) { rep(j, 1, n) { if (i == 1) { if (a[i][j * 2] == '>') { b[i][j] = 1; } else { b[i][j] = 0; } } else { if (a[i][j * 2 - 1] == '>') { b[i][j] = 1; } else { b[i][j] = 0; } } } } if (b[1][n] == 0 && b[2][n] == 0) { cout << "NO" << '\n'; return ; } if(b[1][1]==0&&b[2][1]==0) { cout<<"NO"<<'\n'; return ; } rep(i,1,2) { rep(j,1,n) { if(i==1) { if(j==1) { continue; } if(b[i][j-1]==0&&b[i+1][j]==0) { cout<<"NO"<<'\n'; return ; } } else if(i==2) { if(j==1) { continue; } if(b[i-1][j-1]==0&&b[i][j-1]==0) { cout<<"NO"<<'\n'; return ; } } } } cout<<"YES"<<'\n'; } int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while (t--) { solve(); } }
|
D
D题暴力枚举相等长度即可
?只是多了个判断罢了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, a, n) for (int i = a; i <= n; i++) #define frep(i, a, n) for (int i = a; i >= n;i--) const int N = 1e6 + 10; void solve() { string s; cin >> s; int ans = 0; frep(i,s.length()/2,1) { int num = 0; for (int j = 0; j + i < s.length(); j++) { if (s[j] == s[j + i] || s[j] == '?' || s[j + i] == '?') { num++; if (num == i) { ans = max(ans, i); } } else { num = 0; } } } cout << ans * 2 << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while (t--) { solve(); } return 0; }
|
收藏[286]PID[95262374]_标题[にゃー]画师[Chakuma]UID[24959868]_acg17.com