답안 #953758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953758 2024-03-26T15:34:01 Z Trisanu_Das 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
153 ms 24144 KB
#include <bits/stdc++.h>
using namespace std;
#include "supertrees.h"
 
int n, par[1005];
 
int find(int u){
  if(par[u] == u) return u;
  par[u] = find(par[u]);
  return par[u];
}
 
void union_(int u, int v){
  par[find(u)] = find(v);
}
 
int construct(vector<vector<int> > p){
  n = p.size();
  for(int i = 0; i < n; i++) par[i] = i;
  vector<vector<int> > b(n, vector<int>(n));
  /*for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(p[i][j] && find(i) != find(j)){
        union_(i, j);
        b[i][j] = b[j][i] = 1;
      }else if(p[i][j] == 3 || (!p[i][j] && find(i) == find(j))) return 0;
    }
  }*/
  
  for(int i = 0; i < n; i++){
        vector<int> v;
        v.push_back(par[i]);
        for(int j = i + 1; j < n; j++){
            if(p[i][j] == 2 && find(i) != find(j)){
                v.push_back(par[j]);
                union_(i, j);
            }
        }
        if(v.size() == 2) return 0;
        for(int k = 0; k + 1 < v.size(); k++) b[v[k]][v[k + 1]] = b[v[k + 1]][v[k]] = 1;
        b[v[0]][v[v.size() - 1]] = b[v[v.size() - 1]][v[0]] = 1;
    }
  for(int i = 0; i < n; i++) b[i][i] = 0;
  build(b);
  return 1;
} 

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:40:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int k = 0; k + 1 < v.size(); k++) b[v[k]][v[k + 1]] = b[v[k + 1]][v[k]] = 1;
      |                        ~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 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 392 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 1192 KB Output is correct
9 Correct 153 ms 23904 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 7 ms 1216 KB Output is correct
13 Correct 153 ms 24144 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too few ways to get from 1 to 2, should be 1 found 0
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -