QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#143415#6705. Medianqzez#AC ✓3ms3716kbC++141.3kb2023-08-21 11:13:132023-08-21 11:13:15

Judging History

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

  • [2023-08-21 11:13:15]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3716kb
  • [2023-08-21 11:13:13]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=100+5,M=N*4+5,K=31650,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,m,x,y,Df[N],Dh,In[N];vector<int> S[N];
bitset<N> f1[N],f2[N];
void Solve(){
	int i,j;scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) S[i].clear(),In[i]=0,f1[i].reset(),f2[i].reset();Dh=0;
	while(m--) scanf("%d%d",&x,&y),S[x].emplace_back(y),In[y]++;
	queue<int> q;for(i=1;i<=n;i++) if(!In[i]) q.emplace(i);
	while(!q.empty()){
		int x=q.front();q.pop();f1[x][x]=1;Df[++Dh]=x;
		for(int i:S[x]) {
			f1[i]|=f1[x];
			if(!--In[i]) q.emplace(i);
		}
	}
	if(Dh^n){
		for(j=1;j<=n;j++) Pc('0');Pc('\n');return;
	}
	for(i=Dh;i;i--) {
		int x=Df[i];for(int j:S[x]) f2[x]|=f2[j];f2[x][x]=1;
	}
	for(i=1;i<=n;i++) Pc(f1[i].count()-1<=n/2&&f2[i].count()-1<=n/2?'1':'0');Pc('\n');
}
int main(){
	int t;scanf("%d",&t);while(t--) Solve();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 3ms
memory: 3652kb

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:

1111111111111
01001000111
111
11111111111
111111111111111
001001000000000
00100
01100
1111111
1000000000000
111101101
111111111
000011111011101
010111111
001100000
0100001001101
1111111111111
001000010000000
10010111011
001000000000100
11111111111
00100000011
11111
01000000110
11101110111
00000
1111...

result:

ok 66 lines