結果

問題 No.5002 stick xor
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2018-05-25 22:34:19
言語 C++11
(gcc 11.4.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 /
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
1,564 KB
testcase_01 AC 42 ms
1,564 KB
testcase_02 AC 32 ms
1,564 KB
testcase_03 AC 9 ms
1,560 KB
testcase_04 AC 51 ms
1,564 KB
testcase_05 AC 9 ms
1,560 KB
testcase_06 AC 8 ms
1,564 KB
testcase_07 AC 9 ms
1,564 KB
testcase_08 AC 9 ms
1,560 KB
testcase_09 AC 48 ms
1,564 KB
testcase_10 AC 25 ms
1,564 KB
testcase_11 AC 10 ms
1,560 KB
testcase_12 AC 60 ms
1,564 KB
testcase_13 AC 52 ms
1,564 KB
testcase_14 AC 67 ms
1,560 KB
testcase_15 AC 10 ms
1,564 KB
testcase_16 AC 51 ms
1,560 KB
testcase_17 AC 11 ms
1,564 KB
testcase_18 AC 9 ms
1,564 KB
testcase_19 AC 46 ms
1,564 KB
testcase_20 AC 76 ms
1,564 KB
testcase_21 AC 16 ms
1,564 KB
testcase_22 AC 63 ms
1,560 KB
testcase_23 AC 13 ms
1,560 KB
testcase_24 AC 53 ms
1,564 KB
testcase_25 AC 74 ms
1,560 KB
testcase_26 AC 9 ms
1,564 KB
testcase_27 AC 43 ms
1,560 KB
testcase_28 AC 28 ms
1,564 KB
testcase_29 AC 15 ms
1,564 KB
testcase_30 AC 11 ms
1,560 KB
testcase_31 AC 16 ms
1,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0