답안 #300393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300393 2020-09-17T06:37:43 Z Dovran 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
290 ms 30308 KB
#include <bits/stdc++.h>
#include "supertrees.h"

#define N 1009
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define sz() size()
#define pb push_back
#define pp() pop_back()

using namespace std;

int n, sz[N], p[N];
vector<vector<int>>c;
int vis[N][N];
vector<pii>a;
vector<pii>b;
/*
void build(vector<vector<int>>m){
	for(int i=0; i<m.sz(); i++){
		for(int j=0; j<m[i].sz(); j++)
			cout<<m[i][j]<<' ';
		cout<<'\n';
	}
}
*/
int ata(int x){
	if(p[x]==x)
		return x;
	return p[x]=ata(p[x]);
}

void dsu(int x, int y){
	x=ata(x);
	y=ata(y);
	
	if(sz[y]>sz[x])
		swap(x, y);
	
	sz[x]+=sz[y];
	p[y]=x, sz[y]=0;
	
	return;
}

int construct(vector<vector<int>>v){
	n=v.sz();
	c.resize(n);
	for(int i=0; i<n; i++)
		sz[i]=1, p[i]=i;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			c[i].pb(0);
			if(v[i][j]==1 and i!=j)
				a.pb({i, j}), v[j][i]=3;
			if(v[i][j]==0)
				b.pb({i, j});
		}
	}
	for(auto i:a){
		if(ata(i.ff)!=ata(i.ss))
			dsu(i.ff, i.ss), c[i.ff][i.ss]=c[i.ss][i.ff]=1;
		
	}
	int asd=0;
	for(auto i:b)
		if(ata(i.ff)==ata(i.ss))
			asd=1;
	if(asd)
		return 0;
	
	build(c);
	return 1;
}
/*
int main(){
	int dsa, qwe;
	vector<vector<int>>v;
	cin>>dsa;
	v.resize(dsa);
	for(int i=0; i<dsa ;i++)
		for(int j=0; j<dsa; j++)
			cin>>qwe, v[i].pb(qwe);
	construct(v);
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1396 KB Output is correct
7 Correct 265 ms 26176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1396 KB Output is correct
7 Correct 265 ms 26176 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 12 ms 1612 KB Output is correct
13 Correct 258 ms 30308 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1276 KB Output is correct
17 Correct 134 ms 18140 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 66 ms 7780 KB Output is correct
21 Correct 262 ms 29756 KB Output is correct
22 Correct 290 ms 30008 KB Output is correct
23 Correct 276 ms 28152 KB Output is correct
24 Correct 271 ms 30008 KB Output is correct
25 Correct 128 ms 19800 KB Output is correct
26 Correct 121 ms 20064 KB Output is correct
27 Correct 272 ms 28084 KB Output is correct
28 Correct 251 ms 30092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Incorrect 0 ms 384 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1396 KB Output is correct
7 Correct 265 ms 26176 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 12 ms 1612 KB Output is correct
13 Correct 258 ms 30308 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1276 KB Output is correct
17 Correct 134 ms 18140 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 66 ms 7780 KB Output is correct
21 Correct 262 ms 29756 KB Output is correct
22 Correct 290 ms 30008 KB Output is correct
23 Correct 276 ms 28152 KB Output is correct
24 Correct 271 ms 30008 KB Output is correct
25 Correct 128 ms 19800 KB Output is correct
26 Correct 121 ms 20064 KB Output is correct
27 Correct 272 ms 28084 KB Output is correct
28 Correct 251 ms 30092 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 1 ms 288 KB Output is correct
32 Incorrect 0 ms 384 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1396 KB Output is correct
7 Correct 265 ms 26176 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 12 ms 1612 KB Output is correct
13 Correct 258 ms 30308 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1276 KB Output is correct
17 Correct 134 ms 18140 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 66 ms 7780 KB Output is correct
21 Correct 262 ms 29756 KB Output is correct
22 Correct 290 ms 30008 KB Output is correct
23 Correct 276 ms 28152 KB Output is correct
24 Correct 271 ms 30008 KB Output is correct
25 Correct 128 ms 19800 KB Output is correct
26 Correct 121 ms 20064 KB Output is correct
27 Correct 272 ms 28084 KB Output is correct
28 Correct 251 ms 30092 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 1 ms 288 KB Output is correct
32 Incorrect 0 ms 384 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -