QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287814 | #7940. Impossible Numbers | PhantomThreshold | WA | 2ms | 6804kb | C++20 | 2.0kb | 2023-12-21 00:30:57 | 2023-12-21 00:30:58 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 210000;
int n,K;
int a[maxn];
int upper[1<<10],bound[1<<10];
int nex[1<<10][10],ac[1<<10][10];
int ai[1<<10][1100];
string num[1<<10];
string findfir(const int S)
{
string si;
for(int i=1,left=0;i<=upper[S];i++)
{
for(int j=(i==1?1:0);j<=9;j++)
{
}
}
if(S&1)
{
ai[S][1]=1;
}
for(int i=1;i<=upper[S];i++)
{
si.push_back('0'+ac[S][ ai[S][i] ]);
}
num[S]=si;
return num[S];
}
string findnex(const int S)
{
int sn= __builtin_popcount(S);
int now=upper[S];
while(now>=1)
{
if(ai[S][now]==sn-1) now--,num[S].pop_back();
else break;
}
if(now>=1)
{
num[S].pop_back();
ai[S][now]++;
num[S].push_back('0'+ac[S][ ai[S][now] ]);
for(int j=now+1;j<=upper[S];j++)
{
ai[S][j]=0;
num[S].push_back('0'+ac[S][ ai[S][j] ]);
}
return num[S];
}
else
{
upper[S]++;
return findfir(S);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin>>n>>K;
for(int i=1;i<=n;i++)
{
for(int j=0;j<6;j++)
{
int x; cin>>x;
a[i]|=1<<x;
}
}
for(int s=0;s<(1<<10);s++)
{
for(int i=1;i<=n;i++) if(s&a[i])
upper[s]++;
upper[s]++;
bound[s]=upper[s];
for(int j=0,ji=0;j<=9;j++) if(s>>j&1)
{
ac[s][ji++]=j;
}
for(int j=9,las=10;j>=0;j--)
{
nex[s][j]=las;
if(s>>j&1) las=j;
}
}
struct cmp
{
bool operator()(const pair<string,int> &p1,const pair<string,int> &p2)const
{
if(p1.first.length() != p2.first.length())
return p1.first.length() > p2.first.length();
return p1>p2;
}
};
priority_queue< pair<string,int>, vector<pair<string,int>>, cmp >Q;
for(int s=2;s<(1<<10);s++)
{
Q.emplace( findfir(s),s );
}
while(K--)
{
string ans;
auto [SS,si]=Q.top();
ans=SS;
vector<int>temps;
while(Q.top().first==SS)
{
temps.push_back(Q.top().second);
Q.pop();
}
for(auto s:temps)
{
Q.emplace( findnex(s),s );
}
cout<<ans<<" \n"[K==0];
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5756kb
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: 6804kb
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: -100
Wrong Answer
time: 2ms
memory: 5748kb
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 333 336 338 339 363 366 383
result:
wrong answer 1st lines differ - expected: '33 66 99 133 166 199 233 266 299 303', found: '33 66 99 333 336 338 339 363 366 383'