답안 #1061713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061713 2024-08-16T12:06:41 Z wood 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
1 ms 348 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;
            }
        }
        if(compset.size()==1) 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;
        }
        res[comp[comp.size()-1]][comp[0]] = res[comp[0]][comp[comp.size()-1]] = 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: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++){
      |                        ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -