QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#26028 | #2833. Hamilton | Hakujitsu | WA | 3ms | 3576kb | C++ | 1.7kb | 2022-04-05 21:57:03 | 2022-04-29 02:45:04 |
Judging History
answer
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{
cerr << " " << H;
debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
int n;
void solve(){
vector<string> mp(n);
for (auto &s : mp) cin >> s;
vector<int> res;
for (int i = 0; i < n; i += 1) {
if(res.empty()) {
res.emplace_back(i);
continue;
}
int zero = 0;
int one = 0;
for (int j = 1; j < res.size(); j += 1) {
if(mp[res[j - 1]][res[j]] == '0') zero += 1;
else one += 1;
}
if(zero == 0) {
res.insert(res.begin(), i);
continue;
}
if(one == 0) {
res.emplace_back(i);
continue;
}
int j = 0;
for (; j + 1 < res.size(); j += 1) {
if(mp[res[j]][res[j + 1]] == '1') {
break;
}
}
if(mp[res[j - 1]][i] == '0' || mp[res[j]][i] == '1') {
res.insert(res.begin() + j, i);
continue;
}
if(mp[res[j]][i] == '0' || mp[res[j + 1]][i] == '1'){
res.insert(res.begin() + j + 1, i);
continue;
}
assert(0);
}
for (int i = 0; i < n; i += 1) {
cout << res[i] + 1 << " \n"[i + 1 == n];
}
}
int main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
while(cin >> n) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3576kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
2 1 3 2 1 3 4
result:
wrong answer case #1: found 2 indices