結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
|
提出日時 | 2020-07-03 21:09:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 1,075 bytes |
コンパイル時間 | 2,277 ms |
コンパイル使用メモリ | 198,016 KB |
最終ジャッジ日時 | 2025-01-11 14:11:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int calc(vector<int> &me, vector<int> &you) { int ret = 0; REP (i, me.size()) { if ((me[i] + 1) % 3 == you[i]) ret += 3; else if (me[i] == you[i]) ++ret; } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<int> me, you; REP (i, 3) { int c; cin >> c; REP (j, c) me.push_back(i); } string t; cin >> t; for (char c: t) you.push_back(string("GCP").find(c)); bool update = true; int ret = calc(me, you); while (update) { update = false; REP (i, me.size()) REP (j, i) { if (me[i] != me[j]) { swap(me[i], me[j]); int tmp = calc(me, you); if (tmp > ret) { ret = tmp; update = true; } else { swap(me[i], me[j]); } } } } cout << calc(me, you) << endl; return 0; }