Submission #1062218

# Submission time Handle Problem Language Result Execution time Memory
1062218 2024-08-16T21:56:28 Z wood Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
0 ms 436 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> reps;
    bool done[n]; memset(done,0,sizeof done);
    for(int i = 0; i<n; i++){
        if(done[i])continue;
        done[i] = true;
        set<int> zeros, ones, twos;
        for(int j = 0; j<n; j++){
            if(p[i][j]==0) zeros.insert(j);
            else if(p[i][j]==1) ones.insert(j);
            else twos.insert(j);
        }
        for(int x : ones){
            for(int j = 0; j<n; j++)
                if((p[x][j]==0&&!zeros.count(j))||(p[x][j]==1&&!ones.count(j))||(p[x][j]==2&&!twos.count(j))) return 0;
        }
        vi comp(ones.begin(),ones.end());
        for(int j = 0; j<comp.size()-1; j++){
            int a = comp[i], b = comp[i+1];
            res[a][b] = res[b][a] = 1;
        }
    }
    build(res);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:47:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int j = 0; j<comp.size()-1; j++){
      |                        ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 436 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 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -