QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#485317#6705. MedianpriudyWA 5ms3716kbC++14929b2024-07-20 16:21:572024-07-20 16:21:57

Judging History

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

  • [2024-07-20 16:21:57]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3716kb
  • [2024-07-20 16:21:57]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,m;
int mp[110][110];
int hx[110];
int px[110];
int cnt;
bool f=0;
void dfs(int now){
	hx[now]=1;
	for(int i=1;i<=n;i++){
		if(now!=i&&mp[now][i]&&!hx[i]){
			dfs(i);
		}
	}
	px[++cnt]=now; 
}
void solve(){
	cin>>n>>m;
	memset(mp,0,sizeof(mp));
	memset(hx,0,sizeof(hx));
	f=0;
	for(int i=1,u,v;i<=m;i++){
		cin>>u>>v;
		if(u==v)f=1;
		mp[v][u]=1;
	}
	if(f==0){
		for(int i=1;i<=n;i++){
			if(!hx[i]){
				dfs(i);
			}
		}
		int x=px[(cnt+1)/2];
		for(int i=1;i<=n;i++){
			if(x==i)cout<<1;
			else cout<<0;
		}
	}
	else {
		for(int i=1;i<=n;i++)cout<<0;
	}cout<<endl;
	return;
}
signed main() {
	//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3664kb

input:

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

output:

01000
000

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 3716kb

input:

66
13 2
9 13
7 11
11 19
9 1
8 1
5 1
2 8
4 2
2 1
5 2
6 3
3 11
3 2
4 6
6 10
9 8
3 5
1 7
5 8
3 9
4 9
6 7
3 1
2 3
11 6
9 4
1 6
5 2
1 5
4 6
8 4
15 15
10 6
15 8
7 6
11 1
5 2
3 4
11 13
4 6
10 12
10 13
1 6
15 2
5 12
13 14
5 3
15 86
14 12
8 1
14 9
8 15
5 10
1 9
11 2
6 2
7 10
10 13
14 5
4 13
5 8
4 10
13 9
6 9...

output:

0000001000000
00000000000
000
00000000100
001000000000000
000100000000000
00000
00000
0100000
0000000100000
000000000
000000010
000000000001000
000100000
100000000
1000000000000
0000010000000
000010000000000
10000000000
000000010000000
00000000000
10000000000
00000
00000000000
00000000000
00000
0000...

result:

wrong answer 1st lines differ - expected: '1111111111111', found: '0000001000000'