QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#557928#9241. Sphinxzhouhuanyi#24 53ms4876kbC++172.3kb2024-09-11 12:24:212024-09-11 12:24:22

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 12:24:22]
  • 评测
  • 测评结果:24
  • 用时:53ms
  • 内存:4876kb
  • [2024-09-11 12:24:21]
  • 提交

answer

#include "sphinx.h"
#include<iostream>
#include<cstdio>
#include<vector>
#define N 250
using namespace std;
int n,srt,belong[N+1],tong[N+1],length,depth[N+1],fa[N+1],rt[N+1],lg[N+1],st[N+1],leng,A[N+1];
vector<int>E[N+1];
vector<int>p[N+1];
bool used[N+1],vis[N+1];
int find(int x)
{
	if (rt[x]==x) return x;
	return rt[x]=find(rt[x]);
}
void unionn(int x,int y)
{
	rt[x]=y;
	return;
}
void add(int x,int y)
{
	E[x].push_back(y),E[y].push_back(x);
	return;
}
int query(int x)
{
	bool op=0;
	vector<int>v(n);
	for (int i=0;i<n;++i) v[i]=n;
	for (int i=0;i<=x;++i) v[i]=-1;
	for (int i=0;i<n;++i)
		if (v[i]==n)
			op=1;
	return perform_experiment(v)-op;
}
int query2(int x,int d)
{
	bool op=0;
	vector<int>v(n);
	for (int i=0;i<n;++i) v[i]=n;
	for (int i=0;i<=x;++i) v[i]=-1;
	v[d]=-1;
	for (int i=0;i<n;++i)
		if (v[i]==n)
			op=1;
	return perform_experiment(v)-op;
}
int query3(int x,int d)
{
	bool op=0;
	vector<int>v(n);
	for (int i=0;i<n;++i) v[i]=n;
	for (int i=2;i<=x;++i) v[tong[i]]=-1;
	v[srt]=d;
	for (int i=0;i<n;++i)
		if (v[i]==n)
			op=1;
	return perform_experiment(v)-op;
}
int get(int x)
{
	vector<int>v(n);
	for (int i=0;i<n;++i)
	{
		for (int j=0;j<n;++j) v[j]=(j==srt)?-1:i;
		if (perform_experiment(v)==1) return i;
	}
	return -1;
}
std::vector<int> find_colours(int SN, std::vector<int> X, std::vector<int> Y) {
	vector<int>G(SN);
	int ps;
	n=SN;
	for (int i=2;i<=N;++i) lg[i]=lg[i>>1]+1;
	for (int i=0;i<X.size();++i) add(X[i],Y[i]);
	fa[0]=-1;
	for (int i=0;i<n;++i) A[i]=query(i);
	for (int i=1;i<n;++i)
	{
		if (A[i]==A[i-1])
		{
			ps=-1;
			for (int j=lg[i];j>=0;--j)
				if (ps+(1<<j)<=i-2&&query2(ps+(1<<j),i)!=A[ps+(1<<j)])
					ps+=(1<<j);
			ps++,belong[i]=belong[ps],p[belong[i]].push_back(i);
		}
		else belong[i]=i,p[belong[i]].push_back(i);
	}
	for (int i=0;i<n;++i)
		if (belong[i]==i)
			tong[++length]=i;
	G[tong[1]]=get(tong[1]),srt=tong[1];
	if (length>=2)
	{
		for (int i=0;i<n;++i)
			if (query3(length,i)==length-1)
			{
				ps=1;
				for (int j=lg[length];j>=0;--j)
					if (ps+(1<<j)<=length&&query3(ps+(1<<j),i)!=ps+(1<<j)-1)
						ps+=(1<<j);
				ps++;
				for (int j=0;j<p[tong[ps]].size();++j) G[p[tong[ps]][j]]=i;
			}
	}
	for (int i=0;i<n;++i)
		if (belong[i]==i)
		{
			for (int j=0;j<p[i].size();++j) G[p[i][j]]=G[i];
		}
	return G;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 1ms
memory: 3820kb

input:

1978433568
2
1
0
1
1978433568
2
1978433568
1
1978433568
1

output:

877694080
-1
2
877694080
-1
-1
877694080
-1
0
877694081
0
0

result:

ok #experiments: 3

Test #2:

score: 3
Accepted
time: 1ms
memory: 4124kb

input:

1978433568
2
1
0
1
1978433568
2
1978433568
2
1978433568
1
1978433568
2
1978433568
1
1978433568
1

output:

877694080
-1
2
877694080
-1
-1
877694080
-1
0
877694080
0
-1
877694080
1
-1
877694080
1
-1
877694081
0
1

result:

ok #experiments: 6

Test #3:

score: 3
Accepted
time: 1ms
memory: 3836kb

input:

1978433568
2
1
0
1
1978433568
2
1978433568
2
1978433568
2
1978433568
1
1978433568
1
1978433568
1
1978433568
2

output:

877694080
-1
2
877694080
-1
-1
877694080
-1
0
877694080
-1
1
877694080
0
-1
877694080
0
-1
877694080
1
-1
877694081
1
0

result:

ok #experiments: 7

Test #4:

score: 3
Accepted
time: 1ms
memory: 3804kb

input:

1978433568
2
1
0
1
1978433568
2
1978433568
1
1978433568
2
1978433568
1

output:

877694080
-1
2
877694080
-1
-1
877694080
-1
0
877694080
-1
1
877694081
1
1

result:

ok #experiments: 4

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #5:

score: 7
Accepted
time: 2ms
memory: 3780kb

input:

1978433568
50
49
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
19784335...

output:

877694080
-1
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
877694080
-1
-1
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
5...

result:

ok #experiments: 205

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 4088kb

input:

1978433568
49
48
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
1978433568
2
1...

output:

877694080
-1
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
877694080
-1
-1
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
4...

result:

wrong answer Vertices 36 and 37 do not have the same color, but they do in returned answer

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 16.5
Acceptable Answer
time: 18ms
memory: 3848kb

input:

1978433568
250
249
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

points 0.50 points  0.5

Test #35:

score: 0
Wrong Answer
time: 29ms
memory: 4108kb

input:

1978433568
250
249
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

wrong answer Vertices 143 and 144 do not have the same color, but they do in returned answer

Subtask #4:

score: 21
Accepted

Test #43:

score: 21
Accepted
time: 46ms
memory: 4876kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2394

Test #44:

score: 21
Accepted
time: 53ms
memory: 4604kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2459

Test #45:

score: 21
Accepted
time: 42ms
memory: 4592kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2460

Test #46:

score: 21
Accepted
time: 39ms
memory: 4604kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2451

Test #47:

score: 21
Accepted
time: 42ms
memory: 4588kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2405

Test #48:

score: 21
Accepted
time: 34ms
memory: 4656kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2436

Test #49:

score: 21
Accepted
time: 47ms
memory: 4656kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2454

Test #50:

score: 21
Accepted
time: 35ms
memory: 4668kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2047

Test #51:

score: 21
Accepted
time: 53ms
memory: 4612kb

input:

1978433568
250
31125
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
10
0
11
0
12
0
13
0
14
0
15
0
16
0
17
0
18
0
19
0
20
0
21
0
22
0
23
0
24
0
25
0
26
0
27
0
28
0
29
0
30
0
31
0
32
0
33
0
34
0
35
0
36
0
37
0
38
0
39
0
40
0
41
0
42
0
43
0
44
0
45
0
46
0
47
0
48
0
49
0
50
0
51
0
52
0
53
0
54
0
55
0
56
0
57
0
5...

output:

877694080
-1
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250
250...

result:

ok #experiments: 2530

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%