結果

問題 No.1149 色塗りゲーム
ユーザー yuji9511yuji9511
提出日時 2020-08-07 21:52:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,386 bytes
コンパイル時間 2,488 ms
コンパイル使用メモリ 201,640 KB
実行使用メモリ 25,844 KB
平均クエリ数 20.52
最終ジャッジ日時 2024-07-17 04:36:13
合計ジャッジ時間 7,769 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
24,580 KB
testcase_01 AC 54 ms
24,836 KB
testcase_02 AC 55 ms
25,220 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 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:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'k' may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'void solve()':
main.cpp:21:12: note: 'k' was declared here
   21 |         ll k,x;
      |            ^

ソースコード

diff #

/*** 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();
}
0