QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56366#2833. HamiltonYaoBIG#WA 2ms3716kbC++1.4kb2022-10-18 23:10:512022-10-18 23:10:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-18 23:10:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3716kb
  • [2022-10-18 23:10:51]
  • 提交

answer

#include "bits/stdc++.h"
#define rep(i, a, n) for (auto i = a; i <= (n); ++i)
#define revrep(i, a, n) for (auto i = n; i >= (a); --i)
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a).size()
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;

void debug_out() { cerr << endl; }
template<class H, class... T> void debug_out(H h, T... t) {
	cerr << " " << to_string(h);
	debug_out(t...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: "; debug_out(__VA_ARGS__)

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
	ios::sync_with_stdio(0); cin.tie(0);

	int n;
	while (cin >> n) {
		vector<string> ss(n);
		for (auto &s: ss) cin >> s;
		vi vec{0, 1};
		rep(v, 2, n - 1) {
			int found = -1;
			rep(i, 0, sz(vec) - 1) {
				int a = vec[(i - 1 + sz(vec)) % sz(vec)];
				int b = vec[i];
				int c = vec[(i + 1) % sz(vec)];
				if (ss[a][b] == '0' && ss[b][c] == '1') {
					found = i;
					break;
				}
			}
			if (found == -1) vec.insert(vec.begin(), v);
			else {
				int a = vec[found];
				if (ss[v][a] == 0) vec.insert(vec.begin() + found + 1, v);
				else vec.insert(vec.begin() + found, v);
			}
		}
		for (auto x: vec) printf("%d ", x + 1);
		puts("");
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3700kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 1 2 
4 3 1 2 

result:

ok 2 cases.

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3716kb

input:

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

output:

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

result:

wrong answer case #2: found 2 indices