답안 #1062244

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062244 2024-08-16T22:40:33 Z wood 슈퍼트리 잇기 (IOI20_supertrees) C++17
21 / 100
177 ms 24148 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));
    int leader[n]; for(int i = 0; i<n; i++) leader[i] = i;
    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);
              done[j] = true;
            }
            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[j], b = comp[j+1];
            res[a][b] = res[b][a] = 1;
            leader[j+1] = i;
        }
    }
    memset(done,0,sizeof done);
    for(int ii = 0; ii<n; ii++){
       // int i = leader[ii];
       // if(done[i]) continue;
       // done[i] = true;
       // set<int> t;
       // for(int j = 0; j<n; j++){
       //     if(p[ii][j]==2) t.insert(j);
       // }
       // for(int x : t){
       //     for(int j = 0; j<n; j++){
       //         if((p[ii][j]==2&&!t.count(j))||(p[ii][j]==0&&t.count(j))) return 0;
       //     }
       // }
       // vi comp(t.begin(),t.end());
       // for(int j = 0; j<comp.size()-1; j++){
       //     int a = comp[j], b = comp[j+1];
       //     res[a][b] = res[b][a] = 1;
       //     leader[j+1] = i;
       // }
       // int a = comp[0], b = comp[n-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:50:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int j = 0; j<comp.size()-1; j++){
      |                        ~^~~~~~~~~~~~~~
supertrees.cpp:31:9: warning: variable 'leader' set but not used [-Wunused-but-set-variable]
   31 |     int leader[n]; for(int i = 0; i<n; i++) leader[i] = i;
      |         ^~~~~~
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 122 ms 22040 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 122 ms 22040 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 7 ms 1372 KB Output is correct
13 Correct 177 ms 23996 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 54 ms 14084 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 35 ms 6400 KB Output is correct
21 Correct 133 ms 24148 KB Output is correct
22 Correct 141 ms 24072 KB Output is correct
23 Correct 138 ms 23892 KB Output is correct
24 Correct 169 ms 24144 KB Output is correct
25 Correct 55 ms 14164 KB Output is correct
26 Correct 53 ms 14164 KB Output is correct
27 Correct 128 ms 24060 KB Output is correct
28 Correct 164 ms 24148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 -
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 122 ms 22040 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 7 ms 1372 KB Output is correct
13 Correct 177 ms 23996 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 54 ms 14084 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 35 ms 6400 KB Output is correct
21 Correct 133 ms 24148 KB Output is correct
22 Correct 141 ms 24072 KB Output is correct
23 Correct 138 ms 23892 KB Output is correct
24 Correct 169 ms 24144 KB Output is correct
25 Correct 55 ms 14164 KB Output is correct
26 Correct 53 ms 14164 KB Output is correct
27 Correct 128 ms 24060 KB Output is correct
28 Correct 164 ms 24148 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 122 ms 22040 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 7 ms 1372 KB Output is correct
13 Correct 177 ms 23996 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 54 ms 14084 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 35 ms 6400 KB Output is correct
21 Correct 133 ms 24148 KB Output is correct
22 Correct 141 ms 24072 KB Output is correct
23 Correct 138 ms 23892 KB Output is correct
24 Correct 169 ms 24144 KB Output is correct
25 Correct 55 ms 14164 KB Output is correct
26 Correct 53 ms 14164 KB Output is correct
27 Correct 128 ms 24060 KB Output is correct
28 Correct 164 ms 24148 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -