Submission #1061710

# Submission time Handle Problem Language Result Execution time Memory
1061710 2024-08-16T12:04:50 Z wood Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
144 ms 24144 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay



int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
    vector<vi> res(n,vi(n));
    vector<vi> comps;
    bool done[n]; memset(done,0,sizeof done);
    for(int i = 0; i<n; i++){
        if(done[i]) continue;
        done[i] = true;
        set<int> compset;
        for(int j = 0; j<n; j++){
            if(p[i][j]){
                  compset.insert(j);
                  done[j] = true;
            }
        }
        for(int x : compset){
            for(int j = 0; j < n; j++){
                 if(p[x][j]==1&&!compset.count(j)||p[x][j]==0&&compset.count(j)) return 0;
            }
        }
        vi comp(compset.begin(),compset.end());
        for(int j = 0; j<comp.size()-1; j++){
            res[comp[j]][comp[j+1]] = res[comp[j+1]][comp[j]] = 1;
        }
    }
    build(res);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:45:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   45 |                  if(p[x][j]==1&&!compset.count(j)||p[x][j]==0&&compset.count(j)) return 0;
supertrees.cpp:49:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int j = 0; j<comp.size()-1; j++){
      |                        ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1392 KB Output is correct
7 Correct 129 ms 23380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1392 KB Output is correct
7 Correct 129 ms 23380 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1204 KB Output is correct
13 Correct 114 ms 23376 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 856 KB Output is correct
17 Correct 61 ms 14164 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 31 ms 6240 KB Output is correct
21 Correct 125 ms 23952 KB Output is correct
22 Correct 112 ms 23892 KB Output is correct
23 Correct 131 ms 24144 KB Output is correct
24 Correct 137 ms 23956 KB Output is correct
25 Correct 62 ms 14136 KB Output is correct
26 Correct 51 ms 14224 KB Output is correct
27 Correct 144 ms 24068 KB Output is correct
28 Correct 121 ms 23892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1392 KB Output is correct
7 Correct 129 ms 23380 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1204 KB Output is correct
13 Correct 114 ms 23376 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 856 KB Output is correct
17 Correct 61 ms 14164 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 31 ms 6240 KB Output is correct
21 Correct 125 ms 23952 KB Output is correct
22 Correct 112 ms 23892 KB Output is correct
23 Correct 131 ms 24144 KB Output is correct
24 Correct 137 ms 23956 KB Output is correct
25 Correct 62 ms 14136 KB Output is correct
26 Correct 51 ms 14224 KB Output is correct
27 Correct 144 ms 24068 KB Output is correct
28 Correct 121 ms 23892 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1392 KB Output is correct
7 Correct 129 ms 23380 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1204 KB Output is correct
13 Correct 114 ms 23376 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 856 KB Output is correct
17 Correct 61 ms 14164 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 31 ms 6240 KB Output is correct
21 Correct 125 ms 23952 KB Output is correct
22 Correct 112 ms 23892 KB Output is correct
23 Correct 131 ms 24144 KB Output is correct
24 Correct 137 ms 23956 KB Output is correct
25 Correct 62 ms 14136 KB Output is correct
26 Correct 51 ms 14224 KB Output is correct
27 Correct 144 ms 24068 KB Output is correct
28 Correct 121 ms 23892 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -