QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#832995#9241. SphinxFlamire#1.5 321ms4920kbC++172.1kb2024-12-26 11:44:552024-12-26 11:44:55

Judging History

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

  • [2024-12-26 11:44:55]
  • 评测
  • 测评结果:1.5
  • 用时:321ms
  • 内存:4920kb
  • [2024-12-26 11:44:55]
  • 提交

answer

#include "sphinx.h"
#include <bits/stdc++.h>
using namespace std;

int n,CC;
vector<int> G[255],C;
// map<vector<int>,int> mp;
int Q(vector<int> E)
{
	// if(mp.find(E)!=mp.end())return mp[E];
	// ++CC;
	return perform_experiment(E);
}
int count_components(const std::vector<int>& S) {
  int components_cnt = 0;
  std::vector<bool> vis(n, false);
  for (int i = 0; i < n; i++) {
    if (vis[i])
      continue;
    components_cnt++;

    std::queue<int> q;
    vis[i] = true;
    q.push(i);
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (int nxt : G[cur])
        if (!vis[nxt] && S[nxt] == S[cur]) {
          vis[nxt] = true;
          q.push(nxt);
        }
    }
  }
  return components_cnt;
}
int fa[255];
int get(int a){return fa[a]==a?a:fa[a]=get(fa[a]);}
vector<int> vh[255];
mt19937 rnd(801);
bool solve(vector<int> S)
{
	if(S.size()<=1)return 0;
	// printf("solve(S:");for(int x:S)printf("%d ",x);printf(")\n");
	vector<int> Sl;
	vector<int> E(n,n),C(n,n);
	for(int x:S)
	{
		for(int y:vh[x])C[y]=-x,E[y]=-1;
	}
	int res=Q(E);
	int cnt=count_components(C);
	if(cnt==res)return 0;
	if(res==count_components(E))
	{
		for(int i=1;i<S.size();++i)
		{
			fa[S[i]]=S[0];
			for(int x:vh[S[i]])vh[S[0]].push_back(x);
		}
		return 1;
	}
	// if(S.size()==2)
	// {
	// 	printf("merge(%d,%d) CNT:%d\n",S[0],S[1],CC);
	// 	fa[S[1]]=S[0];
	// 	for(int x:vh[S[1]])vh[S[0]].push_back(x);
	// 	return 1;
	// }
	do
	{
		shuffle(S.begin(),S.end(),rnd);
		Sl=vector<int>(S.begin(),S.begin()+S.size()/2+1);
	}while(!solve(Sl));
	return 1;
}
std::vector<int> find_colours(int N, std::vector<int> X, std::vector<int> Y) {
  n=N;
  for(int i=0;i<X.size();++i)G[X[i]].push_back(Y[i]),G[Y[i]].push_back(X[i]);
  for(int i=0;i<n;++i)fa[i]=i,vh[i].push_back(i);
  vector<int> all(n,0);
  C.resize(n,n);
  for(int i=0;i<n;++i)all[i]=i;
  while(solve(all))
  {
	vector<int> nall;
	for(int x:all)if(fa[x]==x)nall.push_back(x);
	all=nall;
  }
  for(int i=0;i<n;++i)if(fa[i]==i)for(int v:vh[i])C[v]=i;
  return C;
}

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: 3844kb

input:

1978433568
2
1
0
1
1978433568
1

output:

877694080
-1
-1
877694081
0
0

result:

ok #experiments: 1

Test #2:

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

input:

1978433568
2
1
0
1
1978433568
2

output:

877694080
-1
-1
877694081
0
1

result:

ok #experiments: 1

Test #3:

score: 1.5
Acceptable Answer
time: 0ms
memory: 3776kb

input:

1978433568
2
1
0
1
1978433568
2

output:

877694080
-1
-1
877694081
0
1

result:

points 0.50 points  0.5

Test #4:

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

input:

1978433568
2
1
0
1
1978433568
1

output:

877694080
-1
-1
877694081
0
0

result:

points 0.50 points  0.5

Subtask #2:

score: 0
Runtime Error

Dependency #1:

50%
Acceptable Answer

Test #5:

score: 3.5
Acceptable Answer
time: 1ms
memory: 4124kb

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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
877694081
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

points 0.50 points  0.5

Test #6:

score: 0
Runtime Error

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
3
1...

output:

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

result:


Subtask #3:

score: 0
Runtime Error

Test #34:

score: 0
Runtime Error

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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:


Subtask #4:

score: 0
Runtime Error

Test #43:

score: 10.5
Acceptable Answer
time: 321ms
memory: 4920kb

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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

points 0.50 points  0.5

Test #44:

score: 0
Runtime Error

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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:


Subtask #5:

score: 0
Skipped

Dependency #1:

50%
Acceptable Answer

Dependency #2:

0%