結果
問題 | No.5002 stick xor |
ユーザー | どらら |
提出日時 | 2018-05-26 00:01:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 692 ms / 1,000 ms |
コード長 | 3,047 bytes |
コンパイル時間 | 23,514 ms |
実行使用メモリ | 1,548 KB |
スコア | 40,733 |
最終ジャッジ日時 | 2018-05-26 00:01:37 |
ジャッジサーバーID (参考情報) |
judge8 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 673 ms
1,548 KB |
testcase_01 | AC | 593 ms
1,544 KB |
testcase_02 | AC | 692 ms
1,548 KB |
testcase_03 | AC | 610 ms
1,544 KB |
testcase_04 | AC | 656 ms
1,544 KB |
testcase_05 | AC | 590 ms
1,548 KB |
testcase_06 | AC | 589 ms
1,544 KB |
testcase_07 | AC | 647 ms
1,544 KB |
testcase_08 | AC | 599 ms
1,548 KB |
testcase_09 | AC | 662 ms
1,548 KB |
testcase_10 | AC | 610 ms
1,544 KB |
testcase_11 | AC | 678 ms
1,544 KB |
testcase_12 | AC | 635 ms
1,544 KB |
testcase_13 | AC | 596 ms
1,548 KB |
testcase_14 | AC | 661 ms
1,544 KB |
testcase_15 | AC | 599 ms
1,544 KB |
testcase_16 | AC | 664 ms
1,548 KB |
testcase_17 | AC | 605 ms
1,544 KB |
testcase_18 | AC | 661 ms
1,548 KB |
testcase_19 | AC | 599 ms
1,544 KB |
testcase_20 | AC | 598 ms
1,544 KB |
testcase_21 | AC | 657 ms
1,544 KB |
testcase_22 | AC | 602 ms
1,544 KB |
testcase_23 | AC | 672 ms
1,548 KB |
testcase_24 | AC | 606 ms
1,548 KB |
testcase_25 | AC | 629 ms
1,544 KB |
testcase_26 | AC | 629 ms
1,548 KB |
testcase_27 | AC | 604 ms
1,544 KB |
testcase_28 | AC | 674 ms
1,540 KB |
testcase_29 | AC | 610 ms
1,548 KB |
testcase_30 | AC | 675 ms
1,544 KB |
testcase_31 | AC | 591 ms
1,544 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; double score(int L, const string& parts, const string& prev, string& next){ double ret = 0; rep(i,parts.size()){ if(L <= 15){ if(parts[i] == '1'){ ret += 1.0; if(prev[i] == '1' && next[i] == '1') ret -= 0.2; } }else{ if(parts[i] == '1'){ ret += 1.0; } else { if(prev[i] == '1' && next[i] == '1') ret += 0.8; //else ret -= 10.0; } } } return ret; } int main(){ int N, K; cin >> N >> K; vector<int> L; rep(i,K){ int l; cin >> l; L.push_back(l); } vector<string> A; rep(i,N){ string a; cin >> a; A.push_back(a); } int W0 = 0; rep(y,N) rep(x,N){ if(A[y][x] == '0') W0++; } rep(t, K){ double best_score = -1e18; int best_y = 0, best_x = 0, which = 0; rep(y,N){ rep(x,N){ if(x+L[t]<N){ string prev = ""; string parts = ""; string next = ""; rep(i,L[t]){ if(y-1>=0) prev += A[y-1][x+i]; parts += A[y][x+i]; if(y+1<N) next += A[y+1][x+i]; } if(prev.size() == 0) prev = string(parts.size(), '*'); if(next.size() == 0) next = string(parts.size(), '*'); double d = score(L[t], parts, prev, next); if(best_score < d){ best_score = d; best_y = y; best_x = x; which = 0; } } if(y+L[t]<N){ string prev = ""; string parts = ""; string next = ""; rep(i,L[t]){ if(x-1>=0) prev += A[y+i][x-1]; parts += A[y+i][x]; if(x+1<N) prev += A[y+i][x+1]; } if(prev.size() == 0) prev = string(parts.size(), '*'); if(next.size() == 0) next = string(parts.size(), '*'); double d = score(L[t], parts, prev, next); if(best_score < d){ best_score = d; best_y = y; best_x = x; which = 1; } } } } if(which == 0){ cout << best_y+1 << " " << best_x+1 << " " << best_y+1 << " " << best_x+L[t] << endl; rep(i,L[t]){ if(A[best_y][best_x+i] == '1') A[best_y][best_x+i] = '0'; else A[best_y][best_x+i] = '1'; } }else{ cout << best_y+1 << " " << best_x+1 << " " << best_y+L[t] << " " << best_x+1 << endl; rep(i,L[t]){ if(A[best_y+i][best_x] == '1') A[best_y+i][best_x] = '0'; else A[best_y+i][best_x] = '1'; } } int W1 = 0; rep(y,N) rep(x,N){ if(A[y][x] == '0') W1++; } cerr << W1 - W0 << endl; } int W1 = 0; rep(y,N) rep(x,N){ if(A[y][x] == '0') W1++; } cerr << W1 - W0 << endl; return 0; }