답안 #300821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300821 2020-09-17T14:03:32 Z Sho10 슈퍼트리 잇기 (IOI20_supertrees) C++14
40 / 100
279 ms 40952 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];
vector<ll>v[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++)
{
v[caut(i)].pb(i);
}
for(ll i=0;i<n;i++)
{
    ll x=v[i].size();
    if(x<=1){
        continue;
    }
    for(ll j=1;j<v[i].size();j++)
    {
        ans[v[i][j-1]][v[i][j]]=1;
        ans[v[i][j]][v[i][j-1]]=1;
    }
    if(a[v[i][0]][v[i][1]]==2){
        if(x==2){
            return 0;
        }
        ans[v[i][0]][v[i][x-1]]=1;
        ans[v[i][x-1]][v[i][0]]=1;
    }
}
/*
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;
*/

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:88:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for(ll j=1;j<v[i].size();j++)
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 257 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 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 257 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 252 ms 34172 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 2688 KB Output is correct
17 Correct 119 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 65 ms 11896 KB Output is correct
21 Correct 260 ms 38520 KB Output is correct
22 Correct 261 ms 38776 KB Output is correct
23 Correct 269 ms 38136 KB Output is correct
24 Correct 257 ms 34552 KB Output is correct
25 Correct 110 ms 24312 KB Output is correct
26 Correct 108 ms 24828 KB Output is correct
27 Correct 264 ms 38140 KB Output is correct
28 Correct 259 ms 34552 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 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 12 ms 2432 KB Output is correct
9 Correct 268 ms 34172 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 12 ms 3200 KB Output is correct
13 Correct 268 ms 38264 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 2688 KB Output is correct
17 Correct 119 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 0 ms 384 KB Output is correct
21 Correct 66 ms 12280 KB Output is correct
22 Correct 266 ms 38392 KB Output is correct
23 Correct 258 ms 40952 KB Output is correct
24 Correct 279 ms 38264 KB Output is correct
25 Correct 109 ms 20476 KB Output is correct
26 Correct 116 ms 24328 KB Output is correct
27 Correct 266 ms 40824 KB Output is correct
28 Correct 263 ms 38264 KB Output is correct
29 Correct 110 ms 20472 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 Correct 66 ms 11896 KB Output is correct
5 Correct 259 ms 38284 KB Output is correct
6 Correct 259 ms 38648 KB Output is correct
7 Correct 268 ms 38280 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 65 ms 12152 KB Output is correct
10 Correct 266 ms 38392 KB Output is correct
11 Correct 258 ms 40696 KB Output is correct
12 Correct 264 ms 38136 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Incorrect 1 ms 512 KB Too many ways to get from 0 to 4, should be 1 found no less than 2
16 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 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 257 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 252 ms 34172 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 2688 KB Output is correct
17 Correct 119 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 65 ms 11896 KB Output is correct
21 Correct 260 ms 38520 KB Output is correct
22 Correct 261 ms 38776 KB Output is correct
23 Correct 269 ms 38136 KB Output is correct
24 Correct 257 ms 34552 KB Output is correct
25 Correct 110 ms 24312 KB Output is correct
26 Correct 108 ms 24828 KB Output is correct
27 Correct 264 ms 38140 KB Output is correct
28 Correct 259 ms 34552 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 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 12 ms 2432 KB Output is correct
37 Correct 268 ms 34172 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 12 ms 3200 KB Output is correct
41 Correct 268 ms 38264 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 119 ms 24312 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 0 ms 384 KB Output is correct
48 Correct 0 ms 384 KB Output is correct
49 Correct 66 ms 12280 KB Output is correct
50 Correct 266 ms 38392 KB Output is correct
51 Correct 258 ms 40952 KB Output is correct
52 Correct 279 ms 38264 KB Output is correct
53 Correct 109 ms 20476 KB Output is correct
54 Correct 116 ms 24328 KB Output is correct
55 Correct 266 ms 40824 KB Output is correct
56 Correct 263 ms 38264 KB Output is correct
57 Correct 110 ms 20472 KB Output is correct
58 Correct 1 ms 384 KB Output is correct
59 Correct 1 ms 384 KB Output is correct
60 Correct 6 ms 2560 KB Output is correct
61 Correct 119 ms 24200 KB Output is correct
62 Correct 0 ms 384 KB Output is correct
63 Correct 0 ms 512 KB Output is correct
64 Correct 1 ms 384 KB Output is correct
65 Incorrect 66 ms 12408 KB Too many ways to get from 1 to 269, should be 1 found no less than 2
66 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 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 257 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 252 ms 34172 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 2688 KB Output is correct
17 Correct 119 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 65 ms 11896 KB Output is correct
21 Correct 260 ms 38520 KB Output is correct
22 Correct 261 ms 38776 KB Output is correct
23 Correct 269 ms 38136 KB Output is correct
24 Correct 257 ms 34552 KB Output is correct
25 Correct 110 ms 24312 KB Output is correct
26 Correct 108 ms 24828 KB Output is correct
27 Correct 264 ms 38140 KB Output is correct
28 Correct 259 ms 34552 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 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 12 ms 2432 KB Output is correct
37 Correct 268 ms 34172 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 12 ms 3200 KB Output is correct
41 Correct 268 ms 38264 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 119 ms 24312 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 0 ms 384 KB Output is correct
48 Correct 0 ms 384 KB Output is correct
49 Correct 66 ms 12280 KB Output is correct
50 Correct 266 ms 38392 KB Output is correct
51 Correct 258 ms 40952 KB Output is correct
52 Correct 279 ms 38264 KB Output is correct
53 Correct 109 ms 20476 KB Output is correct
54 Correct 116 ms 24328 KB Output is correct
55 Correct 266 ms 40824 KB Output is correct
56 Correct 263 ms 38264 KB Output is correct
57 Correct 110 ms 20472 KB Output is correct
58 Correct 1 ms 384 KB Output is correct
59 Correct 0 ms 384 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 66 ms 11896 KB Output is correct
62 Correct 259 ms 38284 KB Output is correct
63 Correct 259 ms 38648 KB Output is correct
64 Correct 268 ms 38280 KB Output is correct
65 Correct 1 ms 384 KB Output is correct
66 Correct 65 ms 12152 KB Output is correct
67 Correct 266 ms 38392 KB Output is correct
68 Correct 258 ms 40696 KB Output is correct
69 Correct 264 ms 38136 KB Output is correct
70 Correct 0 ms 384 KB Output is correct
71 Correct 1 ms 384 KB Output is correct
72 Incorrect 1 ms 512 KB Too many ways to get from 0 to 4, should be 1 found no less than 2
73 Halted 0 ms 0 KB -