QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385377 | #4632. Card Shark | james1BadCreeper# | WA | 0ms | 3888kb | C++14 | 1.3kb | 2024-04-10 18:24:47 | 2024-04-10 18:24:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, b;
int t[N];
char s[N];
map<int, set<int>> mp;
int main(void) {
ios::sync_with_stdio(0);
cin >> n >> m >> b;
for (int i = 1; i <= n; ++i) {
cin >> s; int l = strlen(s), res = -1;
for (int j = 0; j < l; ++j)
if (s[j] == '1') {
if (res == -1) res = j % m;
else if (res != j % m) return cout << "-1\n", 0;
}
for (int j = 0; j < l; ++j) {
if (j % m == res && s[j] != '1') return cout << "-1\n", 0;
if (j % m != res && s[j] == '1') return cout << "-1\n", 0;
}
t[i] = l; mp[res].insert(i);
// cout << res << " " << i << "\n";
}
vector<int> ans;
int nw = b - 1, sl = 0;
for (int op = 0; op < n; ++op)
if (mp[nw].empty()) return cout << "-1\n", 0;
else {
int x = *mp[nw].begin();
ans.push_back(x); mp[nw].erase(mp[nw].begin());
sl = (sl + t[x]) % m;
nw = (m - sl + b - 1) % m;
// cout << x << " " << nw << "\n";
}
for (int i : ans) cout << i << " ";
cout << "\n";
return 0;
}
/*
5 4 3
00100010001000100010
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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: 0ms
memory: 3688kb
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: 0ms
memory: 3888kb
input:
1 5 3 001000010000100
output:
1
result:
ok single line: '1 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 5 3 01000 00010
output:
-1
result:
ok single line: '-1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1 5 3 11111
output:
-1
result:
ok single line: '-1'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
10 5 3 000010000100 0001000010000100001 000100 00010 00010000100 0010 00001000010000100001000010 00010 001 001000010
output:
-1
result:
wrong answer 1st lines differ - expected: '6 2 1 9 7 3 10 4 8 5', found: '-1'