結果
問題 | No.2824 Lights Up! (Grid Edition) |
ユーザー | FplusFplusF |
提出日時 | 2024-07-22 21:10:19 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,644 bytes |
コンパイル時間 | 3,710 ms |
コンパイル使用メモリ | 263,516 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-07-26 20:36:31 |
合計ジャッジ時間 | 143,868 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 1,902 ms
6,944 KB |
testcase_04 | AC | 1,902 ms
11,520 KB |
testcase_05 | AC | 1,902 ms
11,520 KB |
testcase_06 | AC | 1,903 ms
11,520 KB |
testcase_07 | WA | - |
testcase_08 | AC | 1,903 ms
11,520 KB |
testcase_09 | AC | 1,903 ms
11,392 KB |
testcase_10 | AC | 1,902 ms
11,520 KB |
testcase_11 | WA | - |
testcase_12 | AC | 1,903 ms
11,392 KB |
testcase_13 | WA | - |
testcase_14 | AC | 1,903 ms
11,392 KB |
testcase_15 | WA | - |
testcase_16 | AC | 1,902 ms
11,392 KB |
testcase_17 | WA | - |
testcase_18 | AC | 1,902 ms
11,392 KB |
testcase_19 | WA | - |
testcase_20 | AC | 1,903 ms
6,940 KB |
testcase_21 | AC | 1,903 ms
8,960 KB |
testcase_22 | AC | 1,902 ms
6,940 KB |
testcase_23 | WA | - |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | WA | - |
testcase_26 | AC | 1,903 ms
6,940 KB |
testcase_27 | WA | - |
testcase_28 | AC | 1,902 ms
6,944 KB |
testcase_29 | WA | - |
testcase_30 | AC | 1,902 ms
6,944 KB |
testcase_31 | WA | - |
testcase_32 | AC | 1,902 ms
6,940 KB |
testcase_33 | AC | 1,902 ms
6,944 KB |
testcase_34 | AC | 1,901 ms
6,940 KB |
testcase_35 | WA | - |
testcase_36 | AC | 1,902 ms
6,944 KB |
testcase_37 | WA | - |
testcase_38 | AC | 1,902 ms
6,944 KB |
testcase_39 | WA | - |
testcase_40 | AC | 1,902 ms
6,944 KB |
testcase_41 | AC | 1,902 ms
6,944 KB |
testcase_42 | AC | 1,901 ms
6,944 KB |
testcase_43 | WA | - |
testcase_44 | AC | 1,902 ms
6,944 KB |
testcase_45 | WA | - |
testcase_46 | AC | 1,903 ms
6,944 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2 ms
6,944 KB |
testcase_49 | AC | 2 ms
6,940 KB |
testcase_50 | AC | 1,901 ms
6,940 KB |
testcase_51 | AC | 2 ms
6,944 KB |
testcase_52 | AC | 2 ms
6,940 KB |
testcase_53 | WA | - |
testcase_54 | AC | 1,902 ms
6,940 KB |
testcase_55 | WA | - |
testcase_56 | AC | 1,901 ms
6,944 KB |
testcase_57 | AC | 1,902 ms
6,940 KB |
testcase_58 | AC | 1,902 ms
6,944 KB |
testcase_59 | WA | - |
testcase_60 | AC | 1,902 ms
6,940 KB |
testcase_61 | WA | - |
testcase_62 | AC | 1,902 ms
6,940 KB |
testcase_63 | WA | - |
testcase_64 | AC | 1,902 ms
6,940 KB |
testcase_65 | AC | 1,902 ms
6,940 KB |
testcase_66 | AC | 1,902 ms
6,940 KB |
testcase_67 | WA | - |
testcase_68 | AC | 2 ms
6,944 KB |
testcase_69 | AC | 1,902 ms
6,940 KB |
testcase_70 | AC | 1,901 ms
6,940 KB |
testcase_71 | AC | 1,902 ms
6,944 KB |
testcase_72 | AC | 1,903 ms
6,944 KB |
testcase_73 | AC | 1,901 ms
6,940 KB |
testcase_74 | AC | 1,902 ms
6,944 KB |
testcase_75 | AC | 1,901 ms
6,940 KB |
testcase_76 | AC | 1,902 ms
6,944 KB |
testcase_77 | AC | 1,903 ms
6,944 KB |
testcase_78 | AC | 1,902 ms
6,940 KB |
testcase_79 | AC | 1,901 ms
6,944 KB |
testcase_80 | AC | 1,902 ms
6,940 KB |
testcase_81 | AC | 1,901 ms
6,944 KB |
testcase_82 | AC | 1,902 ms
6,944 KB |
testcase_83 | AC | 2 ms
6,940 KB |
testcase_84 | AC | 2 ms
6,940 KB |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | AC | 1,902 ms
6,940 KB |
testcase_89 | AC | 1,902 ms
6,944 KB |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | AC | 1,902 ms
6,944 KB |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | AC | 1,901 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template<class T> inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template<class T> inline bool chmax(T &a,T b){ if(a<b){ a=b; return true; } return false; } namespace timer{ auto start=chrono::system_clock::now(); void snap(){ start=chrono::system_clock::now(); } int get(){ auto now=chrono::system_clock::now(); int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count(); return ms; } } bitset<1000> v[1000]; ll n; inline void a(ll r,ll c){ v[r][c].flip(); v[r][(c-1+n)%n].flip(); v[(r-1+n)%n][c].flip(); v[(r-1+n)%n][(c-1+n)%n].flip(); } inline void b(ll r,ll c){ a(r,c); a(r,0); a(0,c); } inline void sa(ll r,ll c,set<pll> &st){ st.insert({r,c}); st.insert({(r-1+n)%n,c}); st.insert({r,(c-1+n)%n}); st.insert({(r-1+n)%n,(c-1+n)%n}); } inline int sb(ll r,ll c){ set<pll> st; sa(r,c,st); sa(r,0,st); sa(0,c,st); ll ret=0; for(auto [i,j]:st) ret+=v[i][j]; return ret; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll pre_score=0; rep(i,n){ rep(j,n){ char c; cin >> c; if(c=='#'){ v[i][j]=1; pre_score++; } } } vector<vector<ll>> f(n,vector<ll>(n,0)); mt19937 mt; while(true){ ll ms=timer::get(); if(1900<=ms) break; ll i=mt()%n,j=mt()%n; f[i][j]^=1; ll x=sb(i,j); b(i,j); ll y=sb(i,j); ll new_score=pre_score-x+y; double temp=4.0+(0.1-4.0)*(double)ms/1900.0; double prob=exp((double)(pre_score-new_score)/temp); if(1.0*mt()/mt19937::max()<prob){ pre_score=new_score; }else{ f[i][j]^=1; b(i,j); } if(pre_score==0) break; } if(pre_score!=0){ cout << "-1\n"; }else{ vector<pll> ans; rep(i,n){ rep(j,n){ if(f[i][j]) ans.emplace_back(i,j); } } cout << len(ans) << '\n'; for(auto [i,j]:ans){ cout << i+1 << ' ' << j+1 << '\n'; } exit(0); } }