QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291387 | #4632. Card Shark | yyz | WA | 1ms | 3788kb | C++14 | 1.8kb | 2023-12-26 14:42:59 | 2023-12-26 14:43:00 |
Judging History
answer
#include <bits/stdc++.h>
#define V vector
#define Vi vector<int>
#define sz(a) ((int)a.size())
#define fi first
#define se second
#define Int pair<int, int>
#define Inf ((int)1e9)
#define pb push_back
#define ins insert
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define seg int p, int l, int r
#define lid p << 1, l, mid
#define all(a) a.begin(), a.end()
#define rid p << 1 | 1, mid + 1, r
#define mid ((l + r) / 2)
#define Ceil(x, y) (((x) + (y)-1) / (y))
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define IO(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
IO(1);
#endif
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m, B, s1 = 0, ss = 0;
cin >> n >> m >> B, B--;
V<V<Int>> e(m + 5);
Vi d(m + 5);
For(i, 1, n) {
string st;
cin >> st;
int lst = 0;
For(j, 0, sz(st) - 1) if (st[j] == '1') {
if (!lst)
lst = j % m;
else {
if (lst != j % m) return cout << "-1\n", 0;
}
s1++;
}
int L = (B - lst + m) % m, R = (L + sz(st)) % m;
e[L].pb({R, i}), d[L]++, d[R]--;
ss += sz(st);
}
if (ss / m != s1) return cout << "-1\n", 0;
int sta = 0, sd = 0;
For(i, 1, m - 1) if (d[i] > 0) return cout << "-1\n", 0;
if (d[0] != 0 && d[0] != 1) return cout << "-1\n", 0;
Vi res;
auto dfs = [&](auto lf, int x) -> void {
while (sz(e[x])) {
int y = e[x].back().fi, z = e[x].back().se;
e[x].pop_back();
lf(lf, y);
res.pb(z);
}
};
dfs(dfs, 0);
reverse(all(res));
if (sz(res) < n) return cout << "-1\n", 0;
for (int x : res) cout << x << ' ';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3788kb
input:
5 4 3 0100010 00100 001000100 0010 0100010
output:
4 3 5 2 1
result:
wrong answer 1st lines differ - expected: '2 1 3 5 4', found: '4 3 5 2 1 '