結果
問題 | No.1149 色塗りゲーム |
ユーザー |
|
提出日時 | 2020-08-07 22:34:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 2,310 bytes |
コンパイル時間 | 2,395 ms |
コンパイル使用メモリ | 199,752 KB |
最終ジャッジ日時 | 2025-01-12 17:21:06 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
/*** author: yuji9511 ***/ #include <bits/stdc++.h> using namespace std; using ll = long long; using lpair = pair<ll, ll>; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);i>=(n);i--) #define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];}; void print() {} template <class H,class... T> void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);} void solve(){ ll N; cin >> N; ll state[110] = {}; state[N] = 1; while(true){ ll K = -1,X = -1; bool end = false; // printa(state,N); rep(i,0,N){ rep(k,1,3){ if(state[i] == 1) continue; if(k == 2 && state[i+1] == 1) continue; rep(j,i,i+k){ state[j] = 1; } ll num = 0; map<ll,ll> mp; rep(j,0,N+1){ if(state[j] == 0){ num++; }else{ if(num > 0){ mp[num]++; num = 0; } } } rep(j,i,i+k){ state[j] = 0; } bool ok = true; for(auto &e: mp){ if(e.second % 2 == 1) ok = false; } if(ok){ end = true; // print("ok",k,i); K = k; X = i; break; } } if(end) break; } if(K == -1 || X == -1){ exit(1); } rep(i,X,X+K){ state[i] = 1; } cout << K << " " << X+1 << endl; ll t; cin >> t; if(t == 0 || t == 2){ return; }else if(t == 1){ // exit(1); }else{ ll k,x; cin >> k >> x; if(k == 1){ state[x-1] = 1; }else{ state[x-1] = 1; state[x] = 1; } } } } int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); }