結果
問題 |
No.1149 色塗りゲーム
|
ユーザー |
|
提出日時 | 2020-08-07 21:52:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,386 bytes |
コンパイル時間 | 2,135 ms |
コンパイル使用メモリ | 192,800 KB |
最終ジャッジ日時 | 2025-01-12 16:41:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 47 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:70:31: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 70 | cout << k << " " << x+1 << endl; | ^ main.cpp:21:14: note: ‘x’ was declared here 21 | ll k,x; | ^ In file included from /usr/include/c++/13/istream:41, from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from main.cpp:2: In member function ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]’, inlined from ‘void solve()’ at main.cpp:70:17: /usr/include/c++/13/ostream:204:25: warning: ‘k’ may be used uninitialized [-Wmaybe-uninitialized] 204 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: In function ‘void solve()’: main.cpp:21:12: note: ‘k’ was declared here 21 | ll k,x; | ^
ソースコード
/*** 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,x; ll num = 0; ll cnt = 0; rep(i,0,N+1){ if(state[i] == 0){ num++; }else{ if(num > 0){ cnt++; } num = 0; } } if(cnt % 2 == 0){ rep(i,0,N){ if(state[i] == 0){ k = 1; x = i; state[x] = 1; break; } } }else{ ll num = 0; rep(i,0,N+1){ if(state[i] == 0){ num++; }else{ if(num > 0){ if(num == 1){ k = 1; x = i-1; state[x] = 1; }else if(num == 2){ k = 2; x = i-2; state[x] = 1; state[x+1] = 1; }else{ k = 1; x = i-2; state[x] = 1; } break; } num = 0; } } } 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(); }