QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#425699#961. Smol Vertex CoverKazemaruRE 238ms4108kbC++142.2kb2024-05-30 15:56:092024-05-30 15:56:10

Judging History

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

  • [2024-05-30 15:56:10]
  • 评测
  • 测评结果:RE
  • 用时:238ms
  • 内存:4108kb
  • [2024-05-30 15:56:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,j,k) for(int i=j;i<=k;++i)
#define g(i,j,k) for(int i=j;i>=k;--i)
int n,m,s,l;
inline int read(){
    int x=0;char ch=getchar();
    for(;'0'>ch||ch>'9';ch=getchar());
    for(;'0'<=ch&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
    return x;
}
const int N=2020;
mt19937 rd(time(NULL)^37);
struct Flametail{
	vector<int>q[N];
	int a[N],st[N],sc[N],dfn[N],low[N],vis[N],n,m,s,l;
	inline void init(int N){n=N;m=s=l=0;f(i,0,n*2+9)dfn[i]=vis[i]=st[i]=0,q[i].clear();}
	inline void add(int x,int a,int y,int b){q[x+a*n].push_back(y+b*n);}
	void tj(int x){
		vis[st[++s]=x]=1;
		dfn[x]=low[x]=++l;
		for(int y:q[x]){
			if(!dfn[y])tj(y);
			if(vis[y])low[x]=min(low[x],low[y]);
		}
		if(dfn[x]==low[x])for(++m;st[s+1]!=x;vis[st[s--]]=0)sc[st[s]]=m;
	}
	inline int clac(){
		f(i,1,n*2)if(!dfn[i])tj(i);
		f(i,1,n){
			if(sc[i]==sc[i+n])return 0;
			a[i]=sc[i]>sc[i+n]; 
		}
		return 1;
	}
}F;
struct Kazemaru{
	vector<int>q[N];int v[N],p[N];
	inline void add(int x,int y){q[x].push_back(y);q[y].push_back(x);}
	int dfs(int x){
		int z;v[x]=1;
		shuffle(q[x].begin(),q[x].end(),rd);
		for(int y:q[x])if(!p[y]){
			p[x]=y;p[y]=x;return 1;
		}
		for(int y:q[x])if(!v[z=p[y]]){
			p[x]=y;p[y]=x;p[z]=0;
			if(dfs(z))return 1;
			p[y]=z;p[z]=y;p[x]=0;
		}
		return 0;
	}
	inline int clac(int n,double T){
		auto st=clock();int m=0;
		f(i,1,n)p[i]=0;
		while(clock()-st<T*CLOCKS_PER_SEC){
			f(x,1,n)if(!p[x]){
				f(i,1,n)v[i]=0;
				m+=dfs(x);
			}
		}
		f(i,1,n)q[i].clear();
		return m;
	}
}G;
int a[N][2],b[N],c[N],u[N],v[N],w[N],x,y;
inline void chk(int z){
	F.init(s);
	f(i,1,m)if((x=u[i])!=z&&(y=v[i])!=z){
		if(b[x]+b[y]<1)exit(-1);
		if(!b[x])x=y;if(!b[y])y=x;
		F.add(b[x],!c[x],b[y],c[y]);
		F.add(b[y],!c[y],b[x],c[x]);
	}
	if(!F.clac())return;
	f(i,1,s)w[a[i][F.a[i]]]=1;w[z]=1;
	printf("%lld\n",s+(!!z));
	f(i,1,n)if(w[i])printf("%lld ",i);
	exit(0);
}
signed main(){
	cin>>n>>m;s=0;
	f(i,1,m)G.add(u[i]=read(),v[i]=read());
	G.clac(n,1.5*n*n/250000);
	f(i,1,n)b[i]=w[i]=0;
	f(i,1,n)if(i<(l=G.p[i])){
		a[++s][0]=i;a[s][1]=l;
		b[i]=b[l]=s;c[i]=0;c[l]=1;
	}
	f(i,0,n)chk(i);
	puts("not smol");
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4100kb

input:

5 5
1 2
2 3
3 4
4 5
1 5

output:

3
1 3 5 

result:

ok vertex cover of size 3

Test #2:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

not smol

result:

ok not smol

Test #3:

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

input:

3 0

output:

0

result:

ok vertex cover of size 0

Test #4:

score: 0
Accepted
time: 0ms
memory: 4072kb

input:

10 10
2 5
3 8
3 10
6 9
1 4
2 6
2 3
4 6
7 10
4 7

output:

5
1 2 3 6 7 

result:

ok vertex cover of size 5

Test #5:

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

input:

10 20
1 9
3 6
3 7
8 9
3 8
1 4
5 10
7 10
4 6
7 9
9 10
2 7
1 6
5 8
2 9
1 7
5 7
3 10
2 6
4 10

output:

6
1 2 6 7 8 10 

result:

ok vertex cover of size 6

Test #6:

score: 0
Accepted
time: 14ms
memory: 3908kb

input:

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

output:

not smol

result:

ok not smol

Test #7:

score: 0
Accepted
time: 0ms
memory: 4108kb

input:

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

output:

not smol

result:

ok not smol

Test #8:

score: 0
Accepted
time: 11ms
memory: 4024kb

input:

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

output:

not smol

result:

ok not smol

Test #9:

score: 0
Accepted
time: 238ms
memory: 4008kb

input:

200 300
64 134
92 154
82 142
33 198
26 185
24 74
32 144
26 118
113 122
98 130
74 84
70 184
45 181
44 136
44 134
67 185
77 160
21 50
80 181
62 78
196 199
37 174
91 105
17 74
158 166
26 172
70 129
128 133
152 173
15 86
37 67
55 91
45 74
60 141
179 184
22 168
65 161
62 67
117 152
174 181
35 99
80 103
3...

output:

not smol

result:

ok not smol

Test #10:

score: 0
Accepted
time: 136ms
memory: 4028kb

input:

200 1000
19 159
64 180
15 88
82 136
22 57
92 200
86 87
176 194
57 106
116 179
101 128
27 137
41 71
35 139
48 153
177 178
80 131
9 156
29 122
101 148
88 163
90 116
16 72
8 166
100 116
97 161
19 143
78 163
23 119
104 146
91 161
52 66
183 196
29 123
84 86
41 109
65 76
82 161
138 182
108 156
35 94
101 1...

output:

not smol

result:

ok not smol

Test #11:

score: -100
Runtime Error

input:

200 5000
60 81
22 145
156 181
27 44
49 89
69 176
61 64
16 199
46 50
75 103
26 168
6 35
60 75
51 117
41 105
20 154
69 100
75 195
22 115
67 72
170 190
31 115
10 200
51 129
14 147
161 163
9 72
22 113
70 87
112 184
28 81
178 197
72 180
171 192
71 116
71 174
30 95
20 157
50 125
142 184
18 130
82 110
65 1...

output:


result: