QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#26028#2833. HamiltonHakujitsuWA 3ms3576kbC++1.7kb2022-04-05 21:57:032022-04-29 02:45:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-29 02:45:04]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3576kb
  • [2022-04-05 21:57:03]
  • 提交

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