結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
23,640 KB
testcase_01 AC 41 ms
23,388 KB
testcase_02 AC 41 ms
23,976 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: 関数 ‘void solve()’ 内:
main.cpp:70:31: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
   70 |         cout << k << " " << x+1 << endl;
      |                               ^
main.cpp:21:14: 備考: ‘x’ はここで定義されています
   21 |         ll k,x;
      |              ^
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/istream:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/sstream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/complex:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ccomplex:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54,
         次から読み込み:  main.cpp:2:
メンバ関数 ‘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/local/gcc7/include/c++/12.2.0/ostream:202:25: 警告: ‘k’ may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: 関数 ‘void solve()’ 内:
main.cpp:21:12: 備考: ‘k’ はここで定義されています
   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