QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#242283 | #4632. Card Shark | pakpim | WA | 3ms | 9712kb | C++20 | 1.1kb | 2023-11-07 06:07:17 | 2023-11-07 06:07:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> g[N];
bool f[N];
vector<int> ans;
int main (){
// ios::sync_with_stdio(0); cin.tie(0);
int n,m,b,vis=0;
bool ok=1;
cin >> n >> m >> b;
for (int i=1;i<=n;i++){
string s;
cin >> s;
int st=0,ed=s.size()-1,cnt=0;
while (s[st]=='0') st++;
while (s[ed]=='0') ed--;
for (int j=st+1;j<=ed;j++){
if (s[j]=='0') cnt++;
else{
if (cnt!=m-1) ok=0;
cnt=0;
}
}
if (st>=m || s.size()-ed-1>=m) ok=0;
if (!ok){
cout << -1;
exit(0);
}
g[m-1-st].emplace(i,s.size()-ed-1);
}
int nn=m-b;
while (vis!=n){
if (g[nn].empty()){
cout << -1;
exit(0);
}
auto [ne,xn]=g[nn].top(); g[nn].pop();
ans.emplace_back(ne);
nn=xn;
vis++;
}
for (int i=0;i<n-1;i++) cout << ans[i] << ' ';
cout << ans[n-1];
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 9636kb
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: 3ms
memory: 9712kb
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: 2ms
memory: 9712kb
input:
1 5 3 001000010000100
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 9712kb
input:
2 5 3 01000 00010
output:
-1
result:
ok single line: '-1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 9660kb
input:
1 5 3 11111
output:
-1
result:
ok single line: '-1'
Test #6:
score: -100
Wrong Answer
time: 2ms
memory: 9688kb
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'