답안 #847023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
847023 2023-09-09T02:10:58 Z 12345678 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
1 ms 348 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1e3+5;
int gc;
bool vs[nx];
vector<vector<int>> g(nx);

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	vector<vector<int>> answer(n, vector<int> (n, 0));
	for (int i=0; i<n; i++)
    {
        if (!vs[i])
        {
            queue<int> q;
            q.push(i); vs[i]=1;
            while (!q.empty())
            {
                int x=q.front(); q.pop();
                g[gc].push_back(x);
                for (int j=0; j<n; j++) if (p[x][j]==2&&!vs[j]) q.push(j), vs[j]=1;
                for (int j=0; j<n; j++) if (p[j][x]==2&&!vs[j]) q.push(j), vs[j]=1;
            }
            for (auto x:g[gc]) for (auto y:g[gc]) if (p[x][y]==0) return 0;
            int s=g[gc].size();
            if (s==1) 
            {
                gc++;
                continue;
            }
            for (int j=0; j<g[gc].size(); j++) answer[g[gc][j]][g[gc][(j+1)%s]]=answer[g[gc][(j+1)%s]][g[gc][j]]=1;
            gc++;
        }
    }
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:34:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for (int j=0; j<g[gc].size(); j++) answer[g[gc][j]][g[gc][(j+1)%s]]=answer[g[gc][(j+1)%s]][g[gc][j]]=1;
      |                           ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 0 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 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 -