QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#384815#2833. Hamiltonucup-team1209#WA 0ms3568kbC++201.1kb2024-04-10 12:58:422024-04-10 12:58:43

Judging History

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

  • [2024-04-10 12:58:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3568kb
  • [2024-04-10 12:58:42]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using ll = long long;
const int N = 5005;
int n, m;
int e[N][N];
int main() {
#ifdef zqj
	freopen("$.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false), cin.tie(0);
	for(;cin >> n;) {
		std::vector<int> w, b;
		std::mt19937 gen(12400);
		for(int i = 1;i <= n;++i) {
			for(int j = 1;j <= n;++j) {
				char c; cin >> c;
				e[i][j] = c & 1;
			}
		}
		for(int i = 1;i <= n;++i) {
			for(;w.size();) {
				if(b.size() && e[w.back()][b.back()] == 1) {
					b.push_back(w.back());
					w.pop_back();
				} else {
					break;
				}
			}
			if(w.empty()) {
				w.push_back(i);
			} else if(b.empty()) {
				b.push_back(i);
			} else {
				if(e[b.back()][i] == 1) {
					b.push_back(i);
				} else {
					w.push_back(b.back());
					w.push_back(i);
					b.pop_back();
				}
			}
			for(int i = 1;i < (int) w.size();++i) {
				assert(e[w[i - 1]][w[i]] == 0);
			}
			for(int i = 1;i < (int) b.size();++i) {
				assert(e[b[i - 1]][b[i]] == 1);
			}
		}
		for(int x : w) {
			cout << x << ' ';
		}
		for(int x : b) {
			cout << x << ' ';
		}
		cout << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3560kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
3 2 1 
3 2 1 
3 2 1 

result:

wrong answer case #2: found 2 indices