QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#56364 | #2833. Hamilton | YaoBIG# | WA | 2ms | 3740kb | C++ | 1.2kb | 2022-10-18 22:50:16 | 2022-10-18 22:50:18 |
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};
rep(v, 1, n - 1) {
int found = sz(vec);
rep(i, 0, sz(vec) - 1) {
int x = vec[i];
if (ss[v][x] == '1') {
found = i;
break;
}
}
vec.insert(vec.begin() + found, v);
}
for (auto x: vec) printf("%d ", x + 1);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3716kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
3 1 2 1 2 3 4
result:
ok 2 cases.
Test #2:
score: 0
Accepted
time: 2ms
memory: 3740kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 2 1 3 2 3 1 3 2 1
result:
ok 4 cases.
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3684kb
input:
4 0000 0000 0000 0000 4 0000 0001 0000 0100 4 0100 1010 0100 0000 4 0111 1000 1000 1000 4 0010 0011 1101 0110 4 0111 1011 1100 1100 4 0111 1011 1101 1110 4 0000 0011 0101 0110 4 0101 1010 0100 1000 4 0011 0011 1100 1100 4 0010 0001 1000 0100
output:
1 2 3 4 1 4 2 3 3 2 1 4 2 3 4 1 4 3 1 2 3 4 2 1 4 3 2 1 1 4 3 2 3 2 4 1 3 4 1 2 3 1 4 2
result:
wrong answer case #2: found 2 indices