답안 #1059014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059014 2024-08-14T16:01:05 Z Lalic 슈퍼트리 잇기 (IOI20_supertrees) C++17
11 / 100
104 ms 24112 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;

const int MAXN = 1e3+10;

int pai[MAXN], peso[MAXN];

int find(int x){ return (pai[x]==x ? x : pai[x]=find(pai[x])); }
void join(int a, int b){
	a=find(a);
	b=find(b);
	
	if(a==b) return;
	
	if(peso[a]>peso[b]) swap(a, b);
	pai[a]=b;
	peso[b]=max(peso[a]+1, peso[b]);
}

vector<int> adj[MAXN];

int construct(vector<vector<int>> p) {
	int n = (int)p.size();
	vector<vector<int>> ans(n, vector<int>(n, 0));
	
	for(int i=0;i<n;i++) pai[i]=i, peso[i]=0;
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(p[i][j]==1 && find(i)!=find(j)){
				join(i, j);
				adj[i].pb(j);
				ans[i][j]=ans[j][i]=1;
			}
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(!p[i][j] && find(i)==find(j)){
				cout << i << " " << j << "\n";
				return 0;
			}
		}
	}
	
	build(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 104 ms 24112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 104 ms 24112 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 93 ms 24052 KB Output is correct
14 Incorrect 0 ms 344 KB secret mismatch
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 104 ms 24112 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 93 ms 24052 KB Output is correct
14 Incorrect 0 ms 344 KB secret mismatch
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 104 ms 24112 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 93 ms 24052 KB Output is correct
14 Incorrect 0 ms 344 KB secret mismatch
15 Halted 0 ms 0 KB -