Submission #734882

# Submission time Handle Problem Language Result Execution time Memory
734882 2023-05-03T08:10:46 Z Elvin_Fritl Connecting Supertrees (IOI20_supertrees) C++17
11 / 100
209 ms 24052 KB
#include <bits/stdc++.h>
using namespace std;
 
void build(vector<vector<int> > b);
 
bool vis[1002];
int construct(vector<vector<int> > p) {
    int n = (int)p.size();
    vector<vector<int> > ans(n);
    for(int i=0;i<n;i++) ans[i].resize(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(p[i][j] == 3) return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(vis[i]) continue;
        vis[i] = 1;
 
        vector<int> x;
        vector<vector<int> > y;
        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int u = q.front();
            q.pop();
            vis[u] = 1;
            bool use = 0;
            x.push_back(u);
            vector<int> z;
            for(int v=0;v<n;v++){
                if(vis[v]) continue;
                if(p[u][v] == 0) continue;
                if(p[u][v] == 1){
                    ans[u][v] = 1;
                    ans[v][u] = 1;
                    vis[v] = 1;
                    z.push_back(v);
                }
                else if(!use){
                    use = 1;
                    q.push(v);
                }
            }
            y.push_back(z);
        }
        for(int i=0;i<y.size();i++){
            for(int j=0;j<y[i].size();j++){
                for(int k=j+1;k<y[i].size();k++){
                    if(p[y[i][j]][y[i][k]] != 1) return 0;
                }
            }
            for(int j=0;j<x.size();j++){
                if(i == j) continue;
                for(int k=0;k<y[i].size();k++){
                    if(p[x[j]][y[i][k]] != 2) return 0;
                }
            }
            for(int j=0;j<y.size();j++){
                if(i == j) continue;
                for(int a=0;a<y[i].size();a++){
                    for(int b=0;b<y[j].size();b++){
                        if(p[y[i][a]][y[j][b]] != 2) return 0;
                    }
                }
            }
        }
        for(int i=0;i<x.size();i++){
            for(int j=i+1;j<x.size();j++){
                if(p[x[i]][x[j]] != 2) return 0;
            }
        }
        if((int)x.size() == 2) return 0;
        else if((int)x.size() > 2){
            for(int i=0;i<(int)x.size()-1;i++){
                ans[x[i]][x[i+1]] = 1;
                ans[x[i+1]][x[i]] = 1;
            }
            ans[0][x[(int)x.size()-1]] = 1;
            ans[x[(int)x.size()-1]][0] = 1;
        }
    }
 
    build(ans);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int i=0;i<y.size();i++){
      |                     ~^~~~~~~~~
supertrees.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int j=0;j<y[i].size();j++){
      |                         ~^~~~~~~~~~~~
supertrees.cpp:49:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |                 for(int k=j+1;k<y[i].size();k++){
      |                               ~^~~~~~~~~~~~
supertrees.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             for(int j=0;j<x.size();j++){
      |                         ~^~~~~~~~~
supertrees.cpp:55:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |                 for(int k=0;k<y[i].size();k++){
      |                             ~^~~~~~~~~~~~
supertrees.cpp:59:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             for(int j=0;j<y.size();j++){
      |                         ~^~~~~~~~~
supertrees.cpp:61:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |                 for(int a=0;a<y[i].size();a++){
      |                             ~^~~~~~~~~~~~
supertrees.cpp:62:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |                     for(int b=0;b<y[j].size();b++){
      |                                 ~^~~~~~~~~~~~
supertrees.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for(int i=0;i<x.size();i++){
      |                     ~^~~~~~~~~
supertrees.cpp:69:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |             for(int j=i+1;j<x.size();j++){
      |                           ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 10 ms 1184 KB Output is correct
7 Correct 166 ms 24004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 10 ms 1184 KB Output is correct
7 Correct 166 ms 24004 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 12 ms 1236 KB Output is correct
13 Correct 175 ms 24052 KB Output is correct
14 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 10 ms 1236 KB Output is correct
9 Correct 174 ms 23904 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1204 KB Output is correct
13 Correct 176 ms 23928 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 820 KB Output is correct
17 Correct 99 ms 14032 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Incorrect 45 ms 6220 KB Too many ways to get from 0 to 408, should be 0 found no less than 1
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 44 ms 6248 KB Output is correct
5 Correct 209 ms 24012 KB Output is correct
6 Correct 176 ms 23880 KB Output is correct
7 Correct 193 ms 23912 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Incorrect 61 ms 6256 KB Too many ways to get from 0 to 408, should be 0 found no less than 1
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 10 ms 1184 KB Output is correct
7 Correct 166 ms 24004 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 12 ms 1236 KB Output is correct
13 Correct 175 ms 24052 KB Output is correct
14 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 10 ms 1184 KB Output is correct
7 Correct 166 ms 24004 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 12 ms 1236 KB Output is correct
13 Correct 175 ms 24052 KB Output is correct
14 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -