QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809959#9241. Sphinxhhy061312 217ms4844kbC++172.0kb2024-12-11 18:35:412024-12-11 18:35:45

Judging History

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

  • [2024-12-11 18:35:45]
  • 评测
  • 测评结果:12
  • 用时:217ms
  • 内存:4844kb
  • [2024-12-11 18:35:41]
  • 提交

answer

#include "sphinx.h"
#include<bits/stdc++.h>
using namespace std;
const int N=255;
int n,g[N][N],fa[N],Fa[N];
int find(int x){return (fa[x]==x?x:fa[x]=find(fa[x]));}
int Find(int x){return (Fa[x]==x?x:Fa[x]=Find(Fa[x]));}
void merge(int x,int y){fa[find(x)]=find(y);}
void Merge(int x,int y){Fa[Find(x)]=Find(y);}
vector<int> node[N];
int calc(const vector<int>& E){
	for(int i=0;i<n;++i) Fa[i]=i;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			if(E[i]==n && E[j]==n && g[i][j]==1) Merge(i,j); 
		}
	}
	int ans=0;
	for(int i=0;i<n;++i){
		if(E[i]==n && Fa[i]==i) ++ans;
	}
	return ans;
}
vector<int> find_colours(int nn,vector<int> X,vector<int> Y){
	n=nn;
	memset(g,0,sizeof(g));
	for(int i=0;i<(int)X.size();++i) g[X[i]][Y[i]]=g[Y[i]][X[i]]=1;
	for(int i=0;i<n;++i) fa[i]=i;
	for(int u=0;u<n;++u){
		vector<int> E(n,-1);
		for(int v=0;v<n;++v){
			if((v>u || g[u][v]==0) && u!=v) E[v]=n;
		}
		int tar=0;
		for(int i=0;i<n;++i){
			if(fa[i]==i && E[i]!=n) ++tar;
		}
		if(perform_experiment(E)==tar+calc(E)) continue;
		while(true){
			for(int i=0;i<n;++i) node[i].clear();
			vector<int> vev;
			for(int i=0;i<n;++i) node[find(i)].push_back(i);
			for(int i=0;i<n;++i){
				if(i==find(u)) continue;
				for(int x:node[i]){
					if(x<=u && g[u][x]==1){
						vev.push_back(i);
						break;
					}
				}
			}
			int l=0,r=(int)vev.size(),ans=-1;
			while(l<r){
				int mid=l+(r-l)/2;
				vector<int> F(n,n);
				for(int j=mid;j<(int)vev.size();++j){
					for(int x:node[vev[j]]) F[x]=-1;
				}
				F[u]=-1;
				if(perform_experiment(F)==(int)vev.size()-mid+1+calc(F)) r=mid;
				else{
					ans=mid;
					l=mid+1;
				}
			}
			assert(ans!=-1);
			merge(u,vev[ans]);
			tar=0;
			for(int i=0;i<n;++i){
				if(fa[i]==i && E[i]!=n) ++tar;
			}
			if(perform_experiment(E)==tar+calc(E)) break;
		}
	}
#ifndef HHY
	vector<int> res(n);
	int tot=0;
	for(int i=0;i<n;++i){
		if(fa[i]==i) res[i]=tot++;
	}
	for(int i=0;i<n;++i) res[i]=res[find(i)];
	return res;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1.5
Acceptable Answer

Test #1:

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

input:

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

output:

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

result:

ok #experiments: 4

Test #2:

score: 3
Accepted
time: 0ms
memory: 4064kb

input:

1978433568
2
1
0
1
1978433568
2
1978433568
2

output:

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

result:

ok #experiments: 2

Test #3:

score: 1.5
Acceptable Answer
time: 1ms
memory: 4340kb

input:

1978433568
2
1
0
1
1978433568
2
1978433568
2

output:

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

result:

points 0.50 points  0.5

Test #4:

score: 1.5
Acceptable Answer
time: 1ms
memory: 4028kb

input:

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

output:

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

result:

points 0.50 points  0.5

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

50%
Acceptable Answer

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 4060kb

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:

wrong answer Vertices 1 and 2 do have the same color, but they do not in returned answer

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 27ms
memory: 4132kb

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 1 and 2 do have the same color, but they do not in returned answer

Subtask #4:

score: 10.5
Acceptable Answer

Test #43:

score: 10.5
Acceptable Answer
time: 102ms
memory: 4844kb

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:

points 0.50 points  0.5

Test #44:

score: 10.5
Acceptable Answer
time: 157ms
memory: 4564kb

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:

points 0.50 points  0.5

Test #45:

score: 10.5
Acceptable Answer
time: 200ms
memory: 4508kb

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:

points 0.50 points  0.5

Test #46:

score: 10.5
Acceptable Answer
time: 217ms
memory: 4632kb

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:

points 0.50 points  0.5

Test #47:

score: 10.5
Acceptable Answer
time: 205ms
memory: 4632kb

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:

points 0.50 points  0.5

Test #48:

score: 10.5
Acceptable Answer
time: 152ms
memory: 4616kb

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:

points 0.50 points  0.5

Test #49:

score: 10.5
Acceptable Answer
time: 117ms
memory: 4844kb

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:

points 0.50 points  0.5

Test #50:

score: 10.5
Acceptable Answer
time: 83ms
memory: 4556kb

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:

points 0.50 points  0.5

Test #51:

score: 10.5
Acceptable Answer
time: 34ms
memory: 4540kb

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:

points 0.50 points  0.5

Subtask #5:

score: 0
Skipped

Dependency #1:

50%
Acceptable Answer

Dependency #2:

0%