Submission #627434

# Submission time Handle Problem Language Result Execution time Memory
627434 2022-08-12T15:04:26 Z boonpasin Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 212 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> pcheck;
vector<vector<int>> G;
int m;

void connect(int i, int j){
    G[i][j] = 1;
    G[j][i] = 1;
    bool vis[m];
    for(int i=0;i<m;i++){
        vis[i] = 0;
    }
    queue<int> q;
    q.push(i);
    vis[i] = true;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        if(vis[now]) continue;
        pcheck[now][j]++;
        pcheck[j][now]++;
        vis[now] = true;
        for(int k = 0; k < m; k++){
            if(G[now][j]&&!vis[j]){
                q.push(j);
            }
        }
    }
}

int construct(vector<vector<int>> p) {
    //cout << "hello world";
	m = p.size();
	pcheck.resize(m);
	G.resize(m);
	for(int i = 0; i < m; i++){
        pcheck[i].resize(m);
        G[i].resize(m);
	}
	for(int i=0;i<m;i++){
        G[i][i] = 1;
	}
	for(int I = 0; I < 3; I++){
        for(int i = 0; i < m; i++){
            for(int j = 0; j < m; j++){
                if(pcheck[i][j]==p[i][j]) continue;
                else if(pcheck[i][j]>p[i][j]){
                    /*for(int a=0;a<m;a++){
                        for(int b=0;b<m;b++){
                            cout << pcheck[a][b] << ' ';
                        }
                        cout << endl;
                    }*/
                    return 0;
                }
                else if(p[i][j] > I){
                    connect(i,j);
                }
            }
        }
	}
	build(G);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -