結果
問題 | No.5002 stick xor |
ユーザー |
![]() |
提出日時 | 2018-05-25 22:34:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 76 ms / 1,000 ms |
コード長 | 1,873 bytes |
コンパイル時間 | 2,719 ms |
実行使用メモリ | 1,564 KB |
スコア | 59 |
最終ジャッジ日時 | 2018-05-25 22:34:23 |
ジャッジサーバーID (参考情報) |
judge8 / |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #include <iomanip> using namespace std; typedef long long ll; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(ll i=(a);i<(b);++i) #define per(i,a,b) for(ll i=(b-1);i>=(a);--i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define ctos(c) string(1,c) #define print(x) cout<<#x<<" = "<<x<<endl; #define MOD 1000000007 ll n,k; ll f(vector<string> &vs){ ll score = 0; rep(y,0,n){ rep(x,0,n){ if(vs[y][x]=='0')score++; } } return score; } int main() { cin>>n>>k; vector<ll> v; rep(i,0,k){ ll a; cin>>a; v.pb(a); } vector<string> vs; rep(i,0,n){ string s; cin>>s; vs.pb(s); } ll score = f(vs); rep(i,0,k){ ll a = v[i]; ll mx1 = 0; // v rep(x,0,n){ rep(y,0,n-a+1){ vector<string> vs1 = vs; rep(p,0,a){ if(vs1[y+p][x]=='1'){ vs1[y+p][x]='0'; } else{ vs1[y+p][x]='1'; } } ll score1 = f(vs1); if(score1 > score){ cout << y+1 << " " << x+1 << " " << y+a << " " << x+1 << endl; goto end; } } } // h rep(y,0,n){ rep(x,0,n-a+1){ vector<string> vs1 = vs; rep(p,0,a){ if(vs1[y][x+p]=='1'){ vs1[y][x+p]='0'; } else{ vs1[y][x+p]='1'; } } ll score1 = f(vs1); if(score1 > score){ cout << y+1 << " " << x+1 << " " << y+1 << " " << x+a << endl; goto end; } } } cout << 1 << " " << 1 << " " << 1 << " " << a << endl; end:; } return 0; }