結果

問題 No.5002 stick xor
ユーザー e869120e869120
提出日時 2018-05-25 22:34:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 4,137 ms
実行使用メモリ 1,552 KB
スコア 0
最終ジャッジ日時 2018-05-25 22:34:48
ジャッジサーバーID
(参考情報)
judge9 /
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <ctime>
using namespace std;

struct State {
	int a[66][66];
};

int N, K, L[509]; State S;

void flip(int px, int py, int qx, int qy) {
	for (int i = px; i <= qx; i++) {
		for (int j = py; j <= qy; j++) S.a[i][j] ^= 1;
	}
}
vector<int> solve(vector<int>M, vector<int>query) {
	int maxn = -1; vector<int>V;

	for (int i = 0; i < 1000; i++) {
		vector<int>U = M; vector<int>C;
		for (int j = 0; j < query.size(); j++) {
			int p1 = rand() % (N - query[j] + 1); C.push_back(p1 + 1);
			for (int k = p1; k < p1 + query[j]; k++) U[k] ^= 1;
		}
		int T = 0;
		for (int j = 0; j < U.size(); j++) {
			if (U[j] == 1) T++;
		}
		if (maxn < T) { maxn = T; V = C; }
	}
	return V;
}

int main() {
	srand((unsigned)time(NULL));
	cin >> N >> K;
	for (int i = 1; i <= K; i++) cin >> L[i];
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			char c; cin >> c;
			if (c == '0') S.a[i][j] = 1;
			else S.a[i][j] = 0;
		}
	}
	int s = 1;
	for (int i = 1; i <= N; i++) {
		int t = (K - i + N) / N;
		vector<int>I, J;
		for (int j = s; j < s + t; j++) I.push_back(L[j]);
		for (int j = 1; j <= N; j++) J.push_back(S.a[i][j]);
		vector<int>Y = solve(J, I);
		for (int j = 0; j < Y.size(); j++) {
			cout << i << " " << Y[j] << " " << i << " " << Y[j] + I[j] - 1 << endl;
			flip(i, Y[j], i, Y[j] + I[j] - 1);
		}
	}
	int score = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (S.a[i][j] == 1) score++;
		}
	}
	//cout << "#score = " << score << endl;
	return 0;
}
0