Submission #519856

# Submission time Handle Problem Language Result Execution time Memory
519856 2022-01-27T12:39:14 Z A_D Connecting Supertrees (IOI20_supertrees) C++14
21 / 100
189 ms 26176 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;
const int N=1e3+110;
vector<int> g1[N];
vector<int> g2[N];
int vis[N];
int vis2[N];
vector<vector<int>> answer;
vector<int> vec;


int construct(vector<vector<int>> p){
	int n = p.size();
	vector<int> tmp(n);
	for(int i=0;i<n;i++){
        answer.push_back(tmp);
	}

	for(int i=0;i<n;i++){
        g1[i].push_back(i);
        g2[i].push_back(i);
        for(int j=i;j<n;j++){
            int v=p[i][j];
            if(v==3||(i==j&&v!=1)||p[i][j]!=p[j][i]){
             //   return 0;
            }
            if(v==2){
                g2[i].push_back(j);
                g2[j].push_back(i);

            }
            if(v==1&&i!=j){
                g1[i].push_back(j);
                g1[j].push_back(i);
            }
        }
	}
	for(int i=0;i<n;i++){
        sort(g1[i].begin(),g1[i].end());
        sort(g2[i].begin(),g2[i].end());
	}
	int cnt=0;
	for(int i=0;i<n;i++){
        if(vis[i]==0){
            cnt++;
            int sz=g1[i].size();
            vis[g1[i][0]]=cnt;
            for(int j=0;j<sz-1;j++){
                vis[g1[i][j]]=cnt;
                vis[g1[i][j+1]]=cnt;
                answer[g1[i][j]][g1[i][j+1]]=1;
                answer[g1[i][j+1]][g1[i][j]]=1;
                if(g1[g1[i][j]]!=g1[g1[i][j+1]])return 0;
            }
        }
	}
	//memset(vis,0,sizeof(vis));
	for(int i=0;i<n;i++){
        if(vis2[vis[i]]==0){
            vis2[vis[g2[i][0]]]=1;
            int sz=g2[i].size();
            int lst=g2[i][0];
            for(int j=0;j<sz-1;j++){
                if(g2[g2[i][j]]!=g2[g2[i][j+1]])return 0;
            }
            for(int j=1;j<sz;j++){
                if(vis2[vis[g2[i][j]]]==0){
                    vis2[vis[g2[i][j]]]=1;
                    answer[lst][g2[i][j]]=1;
//                    cout<<lst<<" "<<g2[i][j]<<endl;
                    answer[g2[i][j]][lst]=1;
                    lst=g2[i][j];
                }
            }
  //          cout<<lst<<" "<<g2[i][0]<<endl;
            answer[lst][g2[i][0]]=1;
            answer[g2[i][0]][lst]=1;
        }
	}
	/*
    for(int i=0;i<n;i++)cout<<vis[i]<<" ";cout<<endl;
	for(int i=0;i<n;i++){
        cout<<i<<" : ";
        for(auto y:g1[i]){
            cout<<y<<" ";
        }
        cout<<endl;
    }

    for(int i=0;i<n;i++){
        cout<<i<<" : ";
        for(auto y:g2[i]){
            cout<<y<<" ";
        }
        cout<<endl;
    }
    */

    for(int i=0;i<n;i++){
        answer[i][i]=0;
    }
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 7 ms 1484 KB Output is correct
7 Correct 179 ms 26176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 7 ms 1484 KB Output is correct
7 Correct 179 ms 26176 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 165 ms 22172 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 6 ms 972 KB Output is correct
17 Correct 84 ms 15040 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 42 ms 5864 KB Output is correct
21 Correct 166 ms 22576 KB Output is correct
22 Correct 171 ms 22132 KB Output is correct
23 Correct 180 ms 24172 KB Output is correct
24 Correct 168 ms 22072 KB Output is correct
25 Correct 67 ms 12720 KB Output is correct
26 Correct 67 ms 12224 KB Output is correct
27 Correct 189 ms 25144 KB Output is correct
28 Correct 162 ms 22068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Incorrect 1 ms 332 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 42 ms 5816 KB Output is correct
5 Correct 170 ms 22588 KB Output is correct
6 Correct 161 ms 22068 KB Output is correct
7 Correct 179 ms 24132 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 42 ms 5812 KB Output is correct
10 Correct 168 ms 22576 KB Output is correct
11 Correct 163 ms 22076 KB Output is correct
12 Correct 184 ms 25268 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Incorrect 0 ms 332 KB Answer gives possible 0 while actual possible 1
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 7 ms 1484 KB Output is correct
7 Correct 179 ms 26176 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 165 ms 22172 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 6 ms 972 KB Output is correct
17 Correct 84 ms 15040 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 42 ms 5864 KB Output is correct
21 Correct 166 ms 22576 KB Output is correct
22 Correct 171 ms 22132 KB Output is correct
23 Correct 180 ms 24172 KB Output is correct
24 Correct 168 ms 22072 KB Output is correct
25 Correct 67 ms 12720 KB Output is correct
26 Correct 67 ms 12224 KB Output is correct
27 Correct 189 ms 25144 KB Output is correct
28 Correct 162 ms 22068 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Incorrect 1 ms 332 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 7 ms 1484 KB Output is correct
7 Correct 179 ms 26176 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 165 ms 22172 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 6 ms 972 KB Output is correct
17 Correct 84 ms 15040 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 42 ms 5864 KB Output is correct
21 Correct 166 ms 22576 KB Output is correct
22 Correct 171 ms 22132 KB Output is correct
23 Correct 180 ms 24172 KB Output is correct
24 Correct 168 ms 22072 KB Output is correct
25 Correct 67 ms 12720 KB Output is correct
26 Correct 67 ms 12224 KB Output is correct
27 Correct 189 ms 25144 KB Output is correct
28 Correct 162 ms 22068 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Incorrect 1 ms 332 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -