QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226847 | #7639. Forbidden Set | PhantomThreshold# | AC ✓ | 7ms | 10128kb | C++20 | 941b | 2023-10-26 17:14:06 | 2023-10-26 17:14:06 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int maxn = 510000;
const int inf = 1e9;
int p[maxn],pn,v[maxn];
int f[1<<10];
void pre()
{
for(int i=2;i<maxn;i++)
{
if(!v[i]) p[++pn]=i;
for(int j=1,k=i*p[j];k<maxn;j++,k=i*p[j])
{
v[k]=1;
if(i%p[j]==0) break;
}
}
}
signed main()
{
//freopen("tmp.in","r",stdin);
ios_base::sync_with_stdio(false);
cin.tie(0);
pre();
int N=1<<10;
for(int s=0;s<N;s++) f[s]=inf;
for(int i=1;i<=pn;i++)
{
vector<int>o;
int x=p[i];
while(x) o.push_back(x%10),x/=10;
int s=0;
for(auto c:o) s|=1<<(c);
f[s]=min(f[s],p[i]);
}
for(int i=0;i<=9;i++)
{
for(int s=0;s<N;s++) if(s>>i&1)
f[s]=min(f[s],f[s^1<<i]);
}
int n; cin>>n;
int qs=0;
while(n--)
{
int c; cin>>c;
qs|=1<<(c);
}
qs=(N-1)^qs;
cout<< (f[qs]==inf?-1:f[qs]) <<endl;
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 7ms
memory: 8104kb
input:
7 0 1 2 4 6 8 9
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 7ms
memory: 8132kb
input:
9 0 1 2 3 5 6 7 8 9
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 0
Accepted
time: 7ms
memory: 9764kb
input:
9 0 2 3 4 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #4:
score: 0
Accepted
time: 7ms
memory: 8168kb
input:
9 0 1 3 4 5 6 7 8 9
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 7ms
memory: 8164kb
input:
9 0 1 2 4 5 6 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 6ms
memory: 7972kb
input:
9 0 1 2 3 4 6 7 8 9
output:
5
result:
ok 1 number(s): "5"
Test #7:
score: 0
Accepted
time: 7ms
memory: 7944kb
input:
9 0 1 2 3 4 5 7 8 9
output:
-1
result:
ok 1 number(s): "-1"
Test #8:
score: 0
Accepted
time: 3ms
memory: 7824kb
input:
9 0 1 2 3 4 5 6 8 9
output:
7
result:
ok 1 number(s): "7"
Test #9:
score: 0
Accepted
time: 6ms
memory: 8108kb
input:
9 0 1 2 3 4 5 6 7 9
output:
-1
result:
ok 1 number(s): "-1"
Test #10:
score: 0
Accepted
time: 3ms
memory: 7940kb
input:
9 0 1 2 3 4 5 6 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #11:
score: 0
Accepted
time: 7ms
memory: 7932kb
input:
4 1 3 7 9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 3ms
memory: 9868kb
input:
7 1 2 3 4 5 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #13:
score: 0
Accepted
time: 7ms
memory: 9708kb
input:
8 0 1 2 3 4 5 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #14:
score: 0
Accepted
time: 7ms
memory: 9792kb
input:
8 1 2 3 4 5 6 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #15:
score: 0
Accepted
time: 7ms
memory: 7932kb
input:
5 1 2 3 5 7
output:
89
result:
ok 1 number(s): "89"
Test #16:
score: 0
Accepted
time: 6ms
memory: 7876kb
input:
6 1 2 3 5 7 8
output:
409
result:
ok 1 number(s): "409"
Test #17:
score: 0
Accepted
time: 7ms
memory: 7820kb
input:
8 0 1 2 3 5 6 7 8
output:
449
result:
ok 1 number(s): "449"
Test #18:
score: 0
Accepted
time: 3ms
memory: 7912kb
input:
5 2 3 5 7 9
output:
11
result:
ok 1 number(s): "11"
Test #19:
score: 0
Accepted
time: 7ms
memory: 7912kb
input:
6 1 2 4 5 7 8
output:
3
result:
ok 1 number(s): "3"
Test #20:
score: 0
Accepted
time: 3ms
memory: 8172kb
input:
8 0 1 2 4 5 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #21:
score: 0
Accepted
time: 7ms
memory: 7876kb
input:
8 0 1 3 5 6 7 8 9
output:
2
result:
ok 1 number(s): "2"
Test #22:
score: 0
Accepted
time: 6ms
memory: 7872kb
input:
8 0 2 3 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 7ms
memory: 10128kb
input:
8 0 2 4 5 6 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #24:
score: 0
Accepted
time: 6ms
memory: 7868kb
input:
7 0 2 3 5 6 7 8
output:
11
result:
ok 1 number(s): "11"
Test #25:
score: 0
Accepted
time: 7ms
memory: 7872kb
input:
8 2 3 4 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #26:
score: 0
Accepted
time: 7ms
memory: 7936kb
input:
8 0 1 2 5 6 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #27:
score: 0
Accepted
time: 7ms
memory: 7940kb
input:
1 2
output:
3
result:
ok 1 number(s): "3"
Test #28:
score: 0
Accepted
time: 3ms
memory: 7940kb
input:
10 0 1 2 3 4 5 6 7 8 9
output:
-1
result:
ok 1 number(s): "-1"
Test #29:
score: 0
Accepted
time: 3ms
memory: 8136kb
input:
7 0 2 3 5 6 8 9
output:
7
result:
ok 1 number(s): "7"
Test #30:
score: 0
Accepted
time: 7ms
memory: 7940kb
input:
8 1 2 3 4 5 6 7 9
output:
-1
result:
ok 1 number(s): "-1"
Test #31:
score: 0
Accepted
time: 7ms
memory: 10124kb
input:
4 0 2 6 7
output:
3
result:
ok 1 number(s): "3"
Test #32:
score: 0
Accepted
time: 7ms
memory: 7916kb
input:
5 2 3 4 6 8
output:
5
result:
ok 1 number(s): "5"
Test #33:
score: 0
Accepted
time: 7ms
memory: 9916kb
input:
6 0 2 3 4 5 8
output:
7
result:
ok 1 number(s): "7"
Test #34:
score: 0
Accepted
time: 7ms
memory: 7944kb
input:
3 1 5 7
output:
2
result:
ok 1 number(s): "2"
Test #35:
score: 0
Accepted
time: 3ms
memory: 7932kb
input:
3 1 4 9
output:
2
result:
ok 1 number(s): "2"
Test #36:
score: 0
Accepted
time: 6ms
memory: 7932kb
input:
6 2 3 4 6 7 9
output:
5
result:
ok 1 number(s): "5"
Test #37:
score: 0
Accepted
time: 3ms
memory: 7976kb
input:
7 1 2 3 4 5 6 8
output:
7
result:
ok 1 number(s): "7"
Test #38:
score: 0
Accepted
time: 7ms
memory: 8100kb
input:
6 0 1 3 5 8 9
output:
2
result:
ok 1 number(s): "2"
Test #39:
score: 0
Accepted
time: 3ms
memory: 8168kb
input:
3 1 3 4
output:
2
result:
ok 1 number(s): "2"
Test #40:
score: 0
Accepted
time: 3ms
memory: 7932kb
input:
4 1 5 6 9
output:
2
result:
ok 1 number(s): "2"
Test #41:
score: 0
Accepted
time: 3ms
memory: 7912kb
input:
7 0 2 3 5 6 7 9
output:
11
result:
ok 1 number(s): "11"
Test #42:
score: 0
Accepted
time: 7ms
memory: 8180kb
input:
4 0 3 7 9
output:
2
result:
ok 1 number(s): "2"
Extra Test:
score: 0
Extra Test Passed