QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#56366 | #2833. Hamilton | YaoBIG# | WA | 2ms | 3716kb | C++ | 1.4kb | 2022-10-18 23:10:51 | 2022-10-18 23:10:51 |
Judging History
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