QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342455#4084. 카드 뒤집기 게임Unknown15080 22ms8300kbC++201.2kb2024-03-01 11:27:372024-03-01 11:27:37

Judging History

你现在查看的是最新测评结果

  • [2024-03-01 11:27:37]
  • 评测
  • 测评结果:0
  • 用时:22ms
  • 内存:8300kb
  • [2024-03-01 11:27:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

struct DSU {
	vector<int> parent;

	DSU() {}
	DSU(int N): parent(N, -1) {}

	int get(int x){
		return (parent[x] < 0) ? x : (parent[x] = get(parent[x]));
	}

	bool merge(int a, int b){
		a = get(a); b = get(b);
		if (a == b) return false;

		if (parent[a] > parent[b]) swap(a, b);
		parent[a] += parent[b];
		parent[b] = a;
		return true;
	}
};

bool check(int n, const vector<string> &vec){
	int R = vec.size(), C = vec[0].size();

	DSU dsu((R + C) * 2);

	for (int i = 0; i < R; i++){
		for (int j = 0; j < C; j++){
			if (vec[i][j] == 'X'){
				dsu.merge(R, C + n);
				dsu.merge(R + 1, C + n + 1);
			}
			else{
				dsu.merge(R, C + n + 1);
				dsu.merge(R + 1, C + n);
			}
		}
	}

	for (int i = 0; i < (R + C) * 2; i += 2){
		if (dsu.get(i) == dsu.get(i+1)) return false;
	}
	return true;
}

bool reversal(int n, int m, vector<string> v){
	bool valid = true;
	for (int a = 0; a < m; a++){
		for (int b = 0; b < m; b++){
			vector<string> vec;
			for (int row = a; row < n; row += m){
				vec.emplace_back();
				for (int col = b; col < n; col += m){
					vec.back().push_back(v[row][col]);
				}
			}

			valid &= check(n, vec);
		}
	}
	return valid;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 0ms
memory: 3860kb

input:

10 1
OOOOOOOOOX
XOXXOOOOOO
XOOXOOOXOO
OOOOOOOOOO
OOOXOOOOOO
OOXOOXXOOO
OOOOXOOOOO
XOOOOOOOXO
OOOXXOOOXO
OOOOOOOOOO

output:

0

result:

ok single line: '0'

Test #2:

score: -11
Wrong Answer
time: 0ms
memory: 3796kb

input:

10 1
OOOOOOOOXX
OOOOOOOOXX
XXXXXXXXOO
XXXXXXXXOO
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #46:

score: 50
Accepted
time: 14ms
memory: 8140kb

input:

1000 1
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOXOOOOO...

output:

0

result:

ok single line: '0'

Test #47:

score: -50
Wrong Answer
time: 15ms
memory: 8216kb

input:

1000 1
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOXOOOOOO...

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #3:

score: 0
Wrong Answer

Test #66:

score: 39
Accepted
time: 20ms
memory: 8300kb

input:

1000 1
XXOOXXOXXXOOXXOXOXXXXXXXOOXXOXXXXXXXXOXXOXXXXOXXXXOOOOXXOXOOXOXXXXXOXXXXXOOXXXOOOXOXOXXXXXXXXXXXOXOXXOOXXXOOXXXXOOXXOOOXXOXXOXOXOXXXXXOXXXXOXXXOXXOXXXOXXXXXOXXXXXXOOXOXOXOXOXOXOXXXXXXXOXXXXOXXXXXXXXXOOOOOOXXXXOOOOXXXOXXOOXOXXXXXXXXXOXXOOXXXXOXXXXXXXXXOXXXOOXXOOXOOOXXXXOXOXXOXXXXOOXOXXOOXXXXXO...

output:

0

result:

ok single line: '0'

Test #67:

score: 0
Accepted
time: 22ms
memory: 8176kb

input:

1000 1
XXXXXXXXXOOXXXXOXXXXXXXXXXXOXXXXXOOOXXXOXOXXXXXXXXOXXXXOOXOXXOXXXXOOOXXXXXXXXXXOOXOXXXOOXOXXXXXXXXXXOOXXXXXXOXXOOXXXXXOOXXXXXXXXXOXXXXXXXXXXXXOXXXXXXOXXOXXOXXOOXXXXOOXOXOXXXXXXOOXOXOXXXXXOXXOXOXOXOXXOXOXOXXXXXXXOXXOXXXXXXXXXXOXXXXOOXXOXXOXXXXXXXXOXOOXXXOXOOXXXOXXXXXXXXOXXXXXXOXXXXXXOXXXXXOXXO...

output:

0

result:

ok single line: '0'

Test #68:

score: -39
Wrong Answer
time: 19ms
memory: 8128kb

input:

1000 1
OOOOOOOOXXOOOOXOOOOOOOOOOOXOOOOOXXXOOOXOXOOOOOOOOXOOOOXXOXOOXOOOOXXXOOOOOOOOOOXXOXOOOXXOXOOOOOOOOOOXXOOOOOOXOOXXOOOOOXXOOOOOOOOOXOOOOOOOOOOOOXOOOOOOXOOXOOXOOXXOOOOXXOXOXOOOOOOXXOXOXOOOOOXOOXOXOXOXOOXOXOXOOOOOOOXOOXOOOOOOOOOOXOOOOXXOOXOOXOOOOOOOOXOXXOOOXOXXOOOXOOOOOOOOXOOOOOOXOOOOOOXOOOOOXOOXO...

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'