QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227991 | #7639. Forbidden Set | ucup-team1209# | AC ✓ | 0ms | 3804kb | C++20 | 1.4kb | 2023-10-28 10:28:33 | 2023-10-28 10:28:34 |
Judging History
answer
#include <bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 1e5 + 5;
int n, vis[11];
bool isp (int x) {
for(int i =2; i * i <= x; i++) if(x % i == 0) return false;
return true;
}
int main() {
#ifdef zqj
freopen("1.in","r",stdin);
#endif
cin >> n;
for(int i = 1;i<= n; i++) {
int x;
cin >> x;
vis[x] = 1;
}
if(!vis[2]) {
cout << 2 << '\n';
return 0;
}
if(!vis[3]) {
cout << 3 << '\n';
return 0;
}
if(!vis[5]) {
cout << 5 << '\n';
return 0;
}
if(!vis[7]) {
cout << 7 << '\n';
return 0;
}
if(!vis[1]) {
cout << 11 << '\n';
return 0;
}
if(vis[9]) {
cout << -1 << '\n';
return 0;
}
// 4 6 8 9
if(!vis[8]) {
cout << 89 << '\n';
return 0;
}
// 0 4 6 9
if(vis[4]) {
cout << -1 << '\n';
return 0;
}
priority_queue <int> q;
if(!vis[4]) q.push(-4);
if(!vis[6]) q.push(-6);
while(!q.empty()) {
int x = - q.top();
q.pop();
if(isp(x * 10 + 9)) {
cout << x * 10 + 9 << '\n';
return 0;
}
if(!vis[0]) q.push(- x * 10);
if(!vis[4]) q.push(- (x * 10 + 4));
if(!vis[6]) q.push(- (x * 10 + 6));
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3460kb
input:
7 0 1 2 4 6 8 9
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
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: 0ms
memory: 3756kb
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: 0ms
memory: 3596kb
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: 0ms
memory: 3588kb
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: 0ms
memory: 3724kb
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: 0ms
memory: 3592kb
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: 0ms
memory: 3464kb
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: 0ms
memory: 3588kb
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: 0ms
memory: 3788kb
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: 0ms
memory: 3796kb
input:
4 1 3 7 9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
7 1 2 3 4 5 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
8 0 1 2 3 4 5 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
8 1 2 3 4 5 6 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
5 1 2 3 5 7
output:
89
result:
ok 1 number(s): "89"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
6 1 2 3 5 7 8
output:
409
result:
ok 1 number(s): "409"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
8 0 1 2 3 5 6 7 8
output:
449
result:
ok 1 number(s): "449"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
5 2 3 5 7 9
output:
11
result:
ok 1 number(s): "11"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
6 1 2 4 5 7 8
output:
3
result:
ok 1 number(s): "3"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
8 0 1 2 4 5 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
8 0 1 3 5 6 7 8 9
output:
2
result:
ok 1 number(s): "2"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 0 2 3 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 0 2 4 5 6 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
7 0 2 3 5 6 7 8
output:
11
result:
ok 1 number(s): "11"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
8 2 3 4 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 0 1 2 5 6 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
1 2
output:
3
result:
ok 1 number(s): "3"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3464kb
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: 0ms
memory: 3800kb
input:
7 0 2 3 5 6 8 9
output:
7
result:
ok 1 number(s): "7"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
8 1 2 3 4 5 6 7 9
output:
-1
result:
ok 1 number(s): "-1"
Test #31:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
4 0 2 6 7
output:
3
result:
ok 1 number(s): "3"
Test #32:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 2 3 4 6 8
output:
5
result:
ok 1 number(s): "5"
Test #33:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
6 0 2 3 4 5 8
output:
7
result:
ok 1 number(s): "7"
Test #34:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
3 1 5 7
output:
2
result:
ok 1 number(s): "2"
Test #35:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
3 1 4 9
output:
2
result:
ok 1 number(s): "2"
Test #36:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
6 2 3 4 6 7 9
output:
5
result:
ok 1 number(s): "5"
Test #37:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
7 1 2 3 4 5 6 8
output:
7
result:
ok 1 number(s): "7"
Test #38:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
6 0 1 3 5 8 9
output:
2
result:
ok 1 number(s): "2"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
3 1 3 4
output:
2
result:
ok 1 number(s): "2"
Test #40:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
4 1 5 6 9
output:
2
result:
ok 1 number(s): "2"
Test #41:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
7 0 2 3 5 6 7 9
output:
11
result:
ok 1 number(s): "11"
Test #42:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
4 0 3 7 9
output:
2
result:
ok 1 number(s): "2"
Extra Test:
score: 0
Extra Test Passed