DISCO presents ディスカバリーチャンネル コードコンテスト2017 予選 参加記録
DISCO presents ディスカバリーチャンネル コードコンテスト2017 予選 - AtCoder
ABCの3完、Dは方針はあってたっぽいけど実装が詰められなくて死亡。234位。19年卒じゃない枠で100位以内は本戦だけどきついな〜。
A - DDCC型文字列
やるだけ。
int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
B - 鉛筆
これもやるだけ。
int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C, D; cin >>A >>B>>C>>D; cout << A * 1728 + B * 144 + C * 12 + D << endl; return 0; }
C - 収納
昇順にソートして、貪欲に、箱に入れてない一番大きい棒と一番小さい棒を一緒に入れられたら入れる、入れられないなら大きいのだけ入れる。
int main() { ios::sync_with_stdio(false); cin.tie(0); int N, C; cin >> N >> C; vector<int> L(N); FOR(i,0,N) cin >> L[i]; sort(L.begin(), L.end()); int l = 0, r = N - 1; int ans = 0; while(1) { if(l == r) { ans++; break; } if(l > r) break; if(L[l] + L[r] + 1 <= C) { ans++; r--; l++; } else { ans++; r--; } } cout << ans << endl; return 0; }
D - 石
南北、東西どちらも対称ではない状態ー>どちらかが対称の状態ー>どちらも対称の状態になるように取っていくのが良い。
int main() { int H, W, A, B; cin >> H >> W >> A >> B; vector<string> vs(H); FOR(i,0,H) cin >> vs[i]; int s = 0; FOR(i,0,H) FOR(j,0,W) s += vs[i][j] == 'S'; int ch = 0, cw = 0, chw = 0; FOR(i,0,H/2) { FOR(j,0,W/2) { int cnt = 0; if(vs[i][j] == 'S' && vs[i][W-j-1] == 'S') cw++, cnt++;; if(vs[i][W-j-1] == 'S' && vs[H-i-1][W-j-1] == 'S') ch++, cnt++; if(vs[H-i-1][W-j-1] == 'S' && vs[H-i-1][j] == 'S') cw++, cnt++; if(vs[H-i-1][j] == 'S' && vs[i][j] == 'S') ch++, cnt++; if(cnt == 4) { chw ++; ch -= 2; cw -= 2; } } } //cout << ch << cw << chw << endl; int ans1 = 0, ans2 = 0; // 南北 if(ch > 0 && ch * 2 + chw * 4 != s) ans1 += A; ans1 += max(0, (ch - 1)) * A; if(chw > 0 && chw * 4 != s) ans1 += A + B; ans1 += max(0, (chw - 1)) * (A + B); ans1 += chw * max(A, B); ans1 += A + B; // 東西 if(cw > 0 && cw * 2 + chw * 4 != s) ans2 += B; ans2 += max(0, (cw - 1)) * B; if(chw > 0 && chw * 4 != s) ans2 += A + B; ans2 += max(0, (chw - 1)) * (A + B); ans2 += chw * max(A, B); ans2 += A + B; cout << max(ans1, ans2) << endl; return 0; }
ごめんなさい↓