QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#385390 | #4632. Card Shark | james1BadCreeper# | WA | 1ms | 3876kb | C++14 | 1.3kb | 2024-04-10 18:37:53 | 2024-04-10 18:37:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 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
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
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: 3632kb
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: 1ms
memory: 3876kb
input:
1 5 3 001000010000100
output:
1
result:
ok single line: '1 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
2 5 3 01000 00010
output:
-1
result:
ok single line: '-1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
1 5 3 11111
output:
-1
result:
ok single line: '-1'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3636kb
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'