답안 #300793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300793 2020-09-17T13:33:53 Z Sho10 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
277 ms 38648 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#include "supertrees.h"
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[2005][2005],ans[2005][2005],par[2005],siz[2005];
ll caut(ll x){
if(x==par[x]){
    return x;
}else return par[x]=caut(par[x]);
}
void uni(ll x,ll y){
x=caut(x);
y=caut(y);
ans[x][y]=1;
ans[y][x]=1;
if(siz[x]>siz[y]){
    swap(x,y);
}
siz[y]+=siz[x];
par[x]=y;
}
int construct(vector<vector<int>>p){
n=p[0].size();
for(ll i=0;i<n;i++)
{
    for(ll j=0;j<n;j++)
    {
        a[i][j]=p[i][j];
    }
}
for(ll i=0;i<n;i++)
{
    par[i]=i;
}
for(ll i=0;i<n;i++)
{
    for(ll j=i+1;j<n;j++)
    {
        if(a[i][j]){
            if(caut(i)!=caut(j)){
                uni(i,j);
            }
        }
    }
}
for(ll i=0;i<n;i++)
{
    for(ll j=i+1;j<n;j++)
    {
        if(a[i][j]==0){
            if(caut(i)==caut(j)){
                return 0;
            }
        }
    }
}
/*
for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++)
{
    cout<<ans[i][j]<<' ';
}
cout<<endl;
}
*/
vector<vector<int>>res;
res.resize(n);
for(ll i=0;i<n;i++)
{
    for(ll j=0;j<n;j++)
    {
       res[i].pb(ans[i][j]);
    }
}
build(res);
return 1;
}
/*
int32_t main(){
CODE_START;
construct({1, 1, 2, 2}, {1, 1, 2, 2}, {2, 2, 1, 2], [2, 2, 2, 1]]);
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 268 ms 38136 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 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 268 ms 38136 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 11 ms 2432 KB Output is correct
13 Correct 251 ms 34144 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 6 ms 2560 KB Output is correct
17 Correct 122 ms 24312 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 70 ms 11896 KB Output is correct
21 Correct 276 ms 38264 KB Output is correct
22 Correct 253 ms 38648 KB Output is correct
23 Correct 277 ms 38136 KB Output is correct
24 Correct 253 ms 34424 KB Output is correct
25 Correct 113 ms 24312 KB Output is correct
26 Correct 111 ms 24696 KB Output is correct
27 Correct 268 ms 38136 KB Output is correct
28 Correct 258 ms 34296 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 384 KB Output is correct
4 Incorrect 1 ms 384 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 268 ms 38136 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 11 ms 2432 KB Output is correct
13 Correct 251 ms 34144 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 6 ms 2560 KB Output is correct
17 Correct 122 ms 24312 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 70 ms 11896 KB Output is correct
21 Correct 276 ms 38264 KB Output is correct
22 Correct 253 ms 38648 KB Output is correct
23 Correct 277 ms 38136 KB Output is correct
24 Correct 253 ms 34424 KB Output is correct
25 Correct 113 ms 24312 KB Output is correct
26 Correct 111 ms 24696 KB Output is correct
27 Correct 268 ms 38136 KB Output is correct
28 Correct 258 ms 34296 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 384 KB Output is correct
32 Incorrect 1 ms 384 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 268 ms 38136 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 11 ms 2432 KB Output is correct
13 Correct 251 ms 34144 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 6 ms 2560 KB Output is correct
17 Correct 122 ms 24312 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 70 ms 11896 KB Output is correct
21 Correct 276 ms 38264 KB Output is correct
22 Correct 253 ms 38648 KB Output is correct
23 Correct 277 ms 38136 KB Output is correct
24 Correct 253 ms 34424 KB Output is correct
25 Correct 113 ms 24312 KB Output is correct
26 Correct 111 ms 24696 KB Output is correct
27 Correct 268 ms 38136 KB Output is correct
28 Correct 258 ms 34296 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 384 KB Output is correct
32 Incorrect 1 ms 384 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -