QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123225#2760. Simurgh1kri0 2606ms7256kbC++143.4kb2023-07-11 21:24:392023-07-11 21:24:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-11 21:24:40]
  • 评测
  • 测评结果:0
  • 用时:2606ms
  • 内存:7256kb
  • [2023-07-11 21:24:39]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include "simurgh.h"
using namespace std;
int n,m;
vector<int> u,v;
vector<int> ans;
vector<int> e[505];
int id[505][505];
int fa[505],idx,dfn[505],dfo[505];
bool in_Tree(int a,int b){//whether a is in b
	return (dfn[a]>=dfn[b]&&dfo[a]<=dfo[b]);
}
void dfs(int now,int f){
	fa[now]=f;
	dfn[now]=++idx;
	for (int i=0;i<(int)e[now].size();i++)
		if (e[now][i]!=f&&dfn[e[now][i]]==0)dfs(e[now][i],now);
	dfo[now]=idx;
	return;
}
int dsu[505];
int dsu_find(int x){
	if (x==dsu[x])return x;
	return dsu[x]=dsu_find(dsu[x]); 
} 
pair<vector<int>,int> get_tree(vector<int> id){
	int cnt=0;
	for (int i=0;i<n;i++)dsu[i]=i;
	for (int i=0;i<(int)id.size();i++){
		int x=dsu_find(u[id[i]]),y=dsu_find(v[id[i]]);
		dsu[y]=x;
	}
	for (int i=0;i<m;i++){
		if (ans[i]==-1)continue;
		int x=dsu_find(u[i]),y=dsu_find(v[i]);
		if (x!=y){
			id.push_back(i);
			cnt+=ans[i];
			dsu[y]=x;
		}
	}
	for (int i=0;i<m;i++){
		if (ans[i]!=-1)continue;
		int x=dsu_find(u[i]),y=dsu_find(v[i]);
		if (x!=y){
			id.push_back(i);
			cnt=-1;
			dsu[y]=x;
		}
	}
	return make_pair(id,cnt);
}
vector<int> del(vector<int> a,int x){
	vector<int> ans;
	for (int i=0;i<(int)a.size();i++)
		if (a[i]!=x)ans.push_back(a[i]);
	return ans;
}
void get_circle(vector<int> id){
	int l=(int)id.size();
	vector<int> val(l);
	int x=-1,t=-1;
	for (int i=0;i<l;i++)
		if (ans[id[i]]!=-1)x=id[i];
	if (x!=-1)t=count_common_roads(get_tree(del(id,x)).first)-ans[x];
	else{
		int mn=n+1,mx=-1;
		for (int i=0;i<l;i++){
			val[i]=count_common_roads(get_tree(del(id,id[i])).first);
			mn=min(mn,val[i]);
			mx=max(mx,val[i]);
		}
		if (mn==mx){
			for (int i=0;i<l;i++)ans[id[i]]=0;
		}
		else{
			for (int i=0;i<l;i++)
				if (val[i]==mn)ans[id[i]]=1;
				else ans[id[i]]=0;
		}
		return;
	}
	for (int i=0;i<l;i++)
		if (ans[id[i]]==-1)ans[id[i]]=t-count_common_roads(get_tree(del(id,id[i])).first);
	return;
}
void get_nei(vector<int> id){
	int l=(int)id.size();
	if (l==0)return;
	pair<vector<int>,int> qwq=get_tree(id);
	if (count_common_roads(qwq.first)==qwq.second)return;
	if (l==1){
		ans[id[0]]=1;
		return;
	}
	vector<int> id_l,id_r;
	for (int i=0;i<l/2;i++)id_l.push_back(id[i]);
	for (int i=l/2;i<l;i++)id_r.push_back(id[i]);
	get_nei(id_l);
	get_nei(id_r);
	return;
}
vector<int> find_roads(int _n,vector<int> _u,vector<int> _v){
	n=_n,m=(int)_u.size();
	u=_u,v=_v;
	ans.resize(m);
	for (int i=0;i<m;i++)ans[i]=-1;
	memset(id,-1,sizeof(id));
	for (int i=0;i<m;i++){
		e[u[i]].push_back(v[i]);
		e[v[i]].push_back(u[i]);
		id[u[i]][v[i]]=id[v[i]][u[i]]=i;
	}
	memset(fa,-1,sizeof(fa));
	dfs(0,-1);
	for (int i=1;i<n;i++){
		if (ans[id[fa[i]][i]]!=-1)continue;
		int x=-1,y=-1;
		for (int j=0;j<n&&x==-1;j++)
			if (in_Tree(fa[i],j)){
				for (int k=0;k<n&&x==-1;k++)
					if (in_Tree(k,i)&&(j!=fa[i]||k!=i)&&id[j][k]!=-1){
						x=j,y=k;
						break;
					}
			}
		if (x==-1)ans[id[fa[i]][i]]=1;
		else{
			vector<int> qwq;
			qwq.push_back(id[x][y]);
			while(y!=x)qwq.push_back(id[fa[y]][y]),y=fa[y];
			get_circle(qwq);
		}
	}
	for (int i=0;i<n;i++){
		vector<int> qwq;
		for (int j=0;j<n;j++)
			if (id[i][j]!=-1&&ans[id[i][j]]==-1)qwq.push_back(id[i][j]);
		get_nei(qwq);
	} 
	vector<int> qwq;
	for (int i=0;i<m;i++)
		if (ans[i]==1)qwq.push_back(i);
	return qwq;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 13
Accepted
time: 0ms
memory: 4668kb

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
7 21 30000
2 0
0 1
5 2
2 6
1 3
3 0
6 0
4 5
3 2
4 0
1 4
0 5
4 3
4 6
6 1
2 1
5 3
2 4
5 6
5 1
6 3
7 10 9 13 12 17

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
OK
7 9 10 12 13 17

result:

ok correct

Test #2:

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

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
7 21 30000
4 6
1 6
2 3
0 3
2 1
2 6
5 6
6 3
0 2
1 0
4 2
1 3
5 2
5 0
0 6
5 3
4 5
5 1
3 4
1 4
4 0
4 16 10 0 20 18

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
OK
0 4 10 16 18 20

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 4720kb

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
7 21 30000
2 5
0 4
4 5
4 3
5 3
1 3
3 6
4 1
6 0
5 6
6 2
6 1
6 4
3 2
2 1
1 0
0 2
5 0
5 1
4 2
0 3
20 17 15 9 2 19

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
OK
2 9 15 17 19 20

result:

ok correct

Test #4:

score: -13
Wrong Answer
time: 2ms
memory: 4592kb

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
7 13 30000
2 4
4 3
3 2
0 3
0 4
6 3
6 1
4 5
6 2
1 3
5 6
6 0
6 4
3 9 12 7 0 4

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
WA
NO

result:

wrong answer WA in grader: NO

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #58:

score: 19
Accepted
time: 2ms
memory: 4672kb

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
2 1 12000
1 0
0

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
OK
0

result:

ok correct

Test #59:

score: 0
Accepted
time: 2ms
memory: 4664kb

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
10 45 12000
4 8
0 5
2 0
5 8
8 0
3 8
6 4
4 1
2 3
2 1
6 2
1 7
3 7
8 1
7 0
8 6
0 6
9 5
9 6
7 4
7 6
7 9
1 6
3 5
2 5
7 5
3 9
0 3
3 6
2 9
1 5
0 4
7 8
5 4
9 4
5 6
3 1
2 8
7 2
2 4
1 0
9 8
4 3
1 9
9 0
22 41 3 16 7 25 28 11 39

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
OK
3 7 11 16 22 25 28 39 41

result:

ok correct

Test #60:

score: 0
Accepted
time: 2606ms
memory: 7256kb

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
400 79800 12000
32 64
96 254
115 203
7 171
112 81
124 143
336 175
217 328
152 133
124 331
19 91
92 232
152 43
215 169
4 341
363 18
83 99
52 46
248 66
242 187
150 319
335 158
172 150
3 49
126 256
60 153
165 230
265 68
119 380
171 22
35 169
3...

output:

lxndanfdiadsfnslkj_output_simurgh_faifnbsidjvnsidjbgsidjgbs
OK
191 880 904 936 984 1196 1400 1519 1527 1591 1641 1778 1905 2324 2784 3295 3383 3553 4096 4103 4107 4125 4574 4728 4954 4988 5340 5415 5473 5562 5832 6075 7231 7562 7566 7638 7730 7949 8141 8374 8581 8972 8976 9309 9357 9540 9658 9774 98...

result:

ok correct

Test #61:

score: -19
Time Limit Exceeded

input:

wrslcnopzlckvxbnair_input_simurgh_lmncvpisadngpiqdfngslcnvd
500 124750 12000
81 373
318 76
428 363
341 147
361 355
210 392
305 286
311 54
101 386
387 55
233 144
275 414
328 304
360 389
471 417
152 385
65 468
53 127
376 100
498 472
241 462
259 452
62 224
139 280
42 454
353 455
289 191
5 376
479 277
2...

output:

Unauthorized output

result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%