QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227537#7639. Forbidden Setucup-team1447#AC ✓40ms15136kbC++141.5kb2023-10-27 17:36:472023-10-27 17:36:48

Judging History

This is the latest submission verdict.

  • [2023-10-27 17:36:48]
  • Judged
  • Verdict: AC
  • Time: 40ms
  • Memory: 15136kb
  • [2023-10-27 17:36:47]
  • Submitted

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
 
#define maxn 3000005
#define inf 0x3f3f3f3f

int pri[maxn],phi[maxn],tot;
int mu[maxn],smu[maxn],sphi[maxn];
bool vis[maxn];

int res[1066];

void prework(int n)
{
	vis[1]=1,mu[1]=1,phi[1]=1;
	For(i,2,n)
	{
		if(!vis[i]){
			pri[++tot]=i;
			int s=0;
			int j=i;
			while(j)s|=(1<<(j%10)),j/=10;
			
			bool in=0;
			For(t,0,1023) if(!res[t] && !((t&s))) {
				res[t]=i; in=1;
			}
	//		if(in) cerr<<"i: "<<i<<"\n";
		}
		For(j,1,tot)
		{
			if(i*pri[j]>n)break;
			vis[i*pri[j]]=1;
			if(i%pri[j]){
				
			}else{
				break;
			}
		}
	}
}

signed main()
{
	prework(2e6);
	int n=read(),s=0;
	For(i,1,n){
		int x=read();
		s|=(1<<x);
	}
	if(res[s]==0)res[s]=-1;
	cout<<res[s];
    return 0;
}
/*
5 10 5
01234
0 1

01234

*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 40ms
memory: 14636kb

input:

7
0
1
2
4
6
8
9

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 34ms
memory: 12196kb

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: 35ms
memory: 14620kb

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: 34ms
memory: 14720kb

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: 40ms
memory: 13456kb

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: 35ms
memory: 13468kb

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: 35ms
memory: 14516kb

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: 39ms
memory: 12016kb

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: 35ms
memory: 13576kb

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: 35ms
memory: 14628kb

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: 34ms
memory: 12484kb

input:

4
1
3
7
9

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 35ms
memory: 15136kb

input:

7
1
2
3
4
5
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #13:

score: 0
Accepted
time: 34ms
memory: 12356kb

input:

8
0
1
2
3
4
5
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #14:

score: 0
Accepted
time: 39ms
memory: 12356kb

input:

8
1
2
3
4
5
6
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #15:

score: 0
Accepted
time: 34ms
memory: 11764kb

input:

5
1
2
3
5
7

output:

89

result:

ok 1 number(s): "89"

Test #16:

score: 0
Accepted
time: 38ms
memory: 12256kb

input:

6
1
2
3
5
7
8

output:

409

result:

ok 1 number(s): "409"

Test #17:

score: 0
Accepted
time: 35ms
memory: 11948kb

input:

8
0
1
2
3
5
6
7
8

output:

449

result:

ok 1 number(s): "449"

Test #18:

score: 0
Accepted
time: 40ms
memory: 13232kb

input:

5
2
3
5
7
9

output:

11

result:

ok 1 number(s): "11"

Test #19:

score: 0
Accepted
time: 39ms
memory: 12404kb

input:

6
1
2
4
5
7
8

output:

3

result:

ok 1 number(s): "3"

Test #20:

score: 0
Accepted
time: 39ms
memory: 13436kb

input:

8
0
1
2
4
5
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #21:

score: 0
Accepted
time: 35ms
memory: 12372kb

input:

8
0
1
3
5
6
7
8
9

output:

2

result:

ok 1 number(s): "2"

Test #22:

score: 0
Accepted
time: 39ms
memory: 14880kb

input:

8
0
2
3
5
6
7
8
9

output:

11

result:

ok 1 number(s): "11"

Test #23:

score: 0
Accepted
time: 39ms
memory: 13060kb

input:

8
0
2
4
5
6
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #24:

score: 0
Accepted
time: 35ms
memory: 14644kb

input:

7
0
2
3
5
6
7
8

output:

11

result:

ok 1 number(s): "11"

Test #25:

score: 0
Accepted
time: 35ms
memory: 13140kb

input:

8
2
3
4
5
6
7
8
9

output:

11

result:

ok 1 number(s): "11"

Test #26:

score: 0
Accepted
time: 39ms
memory: 13676kb

input:

8
0
1
2
5
6
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #27:

score: 0
Accepted
time: 39ms
memory: 12196kb

input:

1
2

output:

3

result:

ok 1 number(s): "3"

Test #28:

score: 0
Accepted
time: 38ms
memory: 13056kb

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: 34ms
memory: 13508kb

input:

7
0
2
3
5
6
8
9

output:

7

result:

ok 1 number(s): "7"

Test #30:

score: 0
Accepted
time: 35ms
memory: 13376kb

input:

8
1
2
3
4
5
6
7
9

output:

-1

result:

ok 1 number(s): "-1"

Test #31:

score: 0
Accepted
time: 38ms
memory: 13160kb

input:

4
0
2
6
7

output:

3

result:

ok 1 number(s): "3"

Test #32:

score: 0
Accepted
time: 35ms
memory: 13320kb

input:

5
2
3
4
6
8

output:

5

result:

ok 1 number(s): "5"

Test #33:

score: 0
Accepted
time: 39ms
memory: 13064kb

input:

6
0
2
3
4
5
8

output:

7

result:

ok 1 number(s): "7"

Test #34:

score: 0
Accepted
time: 35ms
memory: 13560kb

input:

3
1
5
7

output:

2

result:

ok 1 number(s): "2"

Test #35:

score: 0
Accepted
time: 35ms
memory: 15100kb

input:

3
1
4
9

output:

2

result:

ok 1 number(s): "2"

Test #36:

score: 0
Accepted
time: 39ms
memory: 14776kb

input:

6
2
3
4
6
7
9

output:

5

result:

ok 1 number(s): "5"

Test #37:

score: 0
Accepted
time: 34ms
memory: 13260kb

input:

7
1
2
3
4
5
6
8

output:

7

result:

ok 1 number(s): "7"

Test #38:

score: 0
Accepted
time: 38ms
memory: 12304kb

input:

6
0
1
3
5
8
9

output:

2

result:

ok 1 number(s): "2"

Test #39:

score: 0
Accepted
time: 38ms
memory: 12268kb

input:

3
1
3
4

output:

2

result:

ok 1 number(s): "2"

Test #40:

score: 0
Accepted
time: 35ms
memory: 13592kb

input:

4
1
5
6
9

output:

2

result:

ok 1 number(s): "2"

Test #41:

score: 0
Accepted
time: 40ms
memory: 13372kb

input:

7
0
2
3
5
6
7
9

output:

11

result:

ok 1 number(s): "11"

Test #42:

score: 0
Accepted
time: 34ms
memory: 11992kb

input:

4
0
3
7
9

output:

2

result:

ok 1 number(s): "2"

Extra Test:

score: 0
Extra Test Passed