QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#286988 | #7940. Impossible Numbers | ucup-team2279 | WA | 1ms | 3576kb | C++14 | 929b | 2023-12-19 10:30:19 | 2023-12-19 10:30:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int S=1<<10;
int n,k,d,h,sz,s[S];
string a;
vector<string> f,g;
void dfs(int x,int p){
if(s[p]>=d) return;
if(x==d){
while(h<sz&&g[h]<a){
f.push_back(g[h]);
cout<<g[h++]<<" ";
if(!--k) exit(0);
}
if(h<sz&&g[h]==a) h++;
f.push_back(a);
cout<<a<<" ";
if(!--k) exit(0);
return;
}
for(int i=x==0;i<10;i++) a+='0'+i,dfs(x+1,p|(1<<i)),a.pop_back();
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>k;
while(n--){
int v=0;
for(int t=6,x;t--;) cin>>x,v|=1<<x;
for(int i=1;i<S;i++) if(v&i) s[i]++;
}
for(d=1;;d++){
g.clear();
for(auto&x:f) for(int i=0;i<d;i++) for(int j=i==0;j<10;j++){
auto y=x;
y.insert(i,1,j+'0');
g.push_back(y);
}
sort(begin(g),end(g));
g.erase(unique(begin(g),end(g)),end(g));
h=0;sz=g.size();f.clear();
dfs(0,0);
while(h<sz) f.push_back(g[h++]);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3492kb
input:
2 3 1 8 7 0 6 2 1 2 5 4 9 3
output:
33 34 35
result:
ok single line: '33 34 35 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
1 10 1 5 2 2 6 4
output:
3 7 8 9 10 11 12 13 14 15
result:
ok single line: '3 7 8 9 10 11 12 13 14 15 '
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
4 10 1 5 7 1 2 4 0 1 5 8 9 4 3 5 2 2 7 8 6 1 7 0 2 2
output:
33 66 99 133 166 199 233 266 299 303
result:
ok single line: '33 66 99 133 166 199 233 266 299 303 '
Test #4:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
5 10 5 9 4 8 3 3 1 1 9 2 8 9 6 3 3 0 2 1 2 6 0 3 6 4 3 6 4 2 9 4
output:
7 17 27 37 47 55 57 67 70 71
result:
ok single line: '7 17 27 37 47 55 57 67 70 71 '
Test #5:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
5 10 8 7 1 4 8 9 2 5 0 1 0 1 9 5 5 3 9 7 6 0 0 2 3 1 1 0 0 4 9 3
output:
66 88 166 188 222 226 262 266 288 366
result:
ok single line: '66 88 166 188 222 226 262 266 288 366 '
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 3576kb
input:
5 10 6 8 7 7 0 0 0 5 1 9 4 1 5 9 6 9 5 4 0 4 6 9 1 6 2 8 7 4 4 0
output:
3 13 22 23 30 31 32 33 103 111
result:
wrong answer 1st lines differ - expected: '3 13 22 23 30 31 32 33 34 35', found: '3 13 22 23 30 31 32 33 103 111 '