QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#522404 | #4632. Card Shark | Achtoria | WA | 5ms | 34136kb | C++14 | 1.4kb | 2024-08-16 22:22:59 | 2024-08-16 22:22:59 |
Judging History
answer
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 1e6 + 5;
struct edge { int v, id; } ;
int n, m, c, l, tp, st[N], cur[N], in[N], out[N]; char s[N];
vector <edge> G[N];
void add (int u, int v, int id) {
++in[v], ++out[u];
G[u].push_back((edge){v, id});
}
void euler (int u) {
for (int &i = cur[u]; i < G[u].size(); ) {
int id = G[u][i].id;
++i, euler(G[u][i - 1].v);
st[++tp] = id;
}
}
int main () {
ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m >> c;
rep(i, 1, n) {
cin >> (s + 1), l = strlen(s + 1);
int lst = 0, fst = 0;
rep(j, 1, l) if (s[j] == '1') {
if (lst && (j - lst) != m) {
cout << -1 << '\n'; return 0;
}
if (!lst) {
fst = j;
if (j > m) {
cout << -1 << '\n'; return 0;
}
}
lst = j;
}
if (l - lst >= m) {
cout << -1 << '\n'; return 0;
}
add((c - fst + m) % m, (c - fst + l + m) % m, i);
}
rep(i, 0, m - 1) if (in[i] != out[i]) {
cout << -1 << '\n'; return 0;
}
rep(i, 0, m - 1) sort(G[i].begin(), G[i].end(), [](edge a, edge b) {
return a.id < b.id;
});
euler(0);
for ( ; tp; --tp) cout << st[tp] << ' '; cout << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 34068kb
input:
5 4 3 0100010 00100 001000100 0010 0100010
output:
2 1 3 5 4
result:
ok single line: '2 1 3 5 4 '
Test #2:
score: 0
Accepted
time: 4ms
memory: 32836kb
input:
4 2 1 010 10101 010 10101
output:
2 1 4 3
result:
ok single line: '2 1 4 3 '
Test #3:
score: 0
Accepted
time: 3ms
memory: 34136kb
input:
1 5 3 001000010000100
output:
1
result:
ok single line: '1 '
Test #4:
score: -100
Wrong Answer
time: 5ms
memory: 30852kb
input:
2 5 3 01000 00010
output:
result:
wrong answer 1st lines differ - expected: '-1', found: ''