답안 #1000317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000317 2024-06-17T08:35:41 Z codefox 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
155 ms 22100 KB
#include<bits/stdc++.h>
#include "supertrees.h"

using namespace std;

int construct(std::vector<std::vector<int>> p) 
{
    int n = p.size();
    vector<int> rep(n);
    iota(rep.begin(), rep.end(), 0);
    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]==3) return 0;
        }
    }
    

    for (int i = 0; i < n; i++)
    {
        if (rep[i]!=i) continue;
        for (int j = i+1; j < n; j++)
        {
            if (p[i][j]!=1) continue;
            for (int k = 0; k < n; k++)
            {
                if (p[i][k]!=p[j][k]) return 0;
            }
            b[i][j] = 1;
            b[j][i] = 1;
            rep[j] = i;
        }
    }
    vector<int> vis(n,0);

    for (int i = 0; i < n; i++)
    {
        if (rep[i]!=i) continue;
        if (vis[i]) continue;
        vector<int> cyc;
        for (int j = i+1; j < n; j++)
        {
            if (p[i][j]!=2) continue;
            if (rep[j]!=j) continue;
            for (int k = 0; k < n; k++)
            {
                if (p[i][k]==1 && rep[k]==i && p[j][k]==2) continue;
                if (p[i][k]==2 && p[j][k]==1 && rep[k]==j) continue;
                if (p[i][k]==2 && p[j][k]==2) continue;
                if (p[i][k]==0 && p[j][k]==0) continue;
                return 0;
            }
            vis[j] = 1;
            cyc.push_back(j);
        }
        if (cyc.empty()) continue;
        if (cyc.size()==1) return 0;
        for (int j = 0; j < cyc.size()-1; j++)
        {
            b[cyc[j]][cyc[j+1]] = 1;
            b[cyc[j+1]][cyc[j]] = 1;
        }
        b[i][cyc.back()] = 1;
        b[cyc.back()][i] = 1;
    }
    build(b);
    return 1;
   
    return 0;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:61:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int j = 0; j < cyc.size()-1; j++)
      |                         ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 424 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 6 ms 1116 KB Output is correct
7 Correct 109 ms 22064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 424 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 6 ms 1116 KB Output is correct
7 Correct 109 ms 22064 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 109 ms 21980 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 852 KB Output is correct
17 Correct 53 ms 12052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 32 ms 5740 KB Output is correct
21 Correct 155 ms 22028 KB Output is correct
22 Correct 109 ms 22068 KB Output is correct
23 Correct 114 ms 22096 KB Output is correct
24 Correct 108 ms 22024 KB Output is correct
25 Correct 51 ms 12116 KB Output is correct
26 Correct 47 ms 12112 KB Output is correct
27 Correct 115 ms 22100 KB Output is correct
28 Correct 108 ms 22036 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 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 424 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 6 ms 1116 KB Output is correct
7 Correct 109 ms 22064 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 109 ms 21980 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 852 KB Output is correct
17 Correct 53 ms 12052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 32 ms 5740 KB Output is correct
21 Correct 155 ms 22028 KB Output is correct
22 Correct 109 ms 22068 KB Output is correct
23 Correct 114 ms 22096 KB Output is correct
24 Correct 108 ms 22024 KB Output is correct
25 Correct 51 ms 12116 KB Output is correct
26 Correct 47 ms 12112 KB Output is correct
27 Correct 115 ms 22100 KB Output is correct
28 Correct 108 ms 22036 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 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 424 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 6 ms 1116 KB Output is correct
7 Correct 109 ms 22064 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 109 ms 21980 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 2 ms 852 KB Output is correct
17 Correct 53 ms 12052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 32 ms 5740 KB Output is correct
21 Correct 155 ms 22028 KB Output is correct
22 Correct 109 ms 22068 KB Output is correct
23 Correct 114 ms 22096 KB Output is correct
24 Correct 108 ms 22024 KB Output is correct
25 Correct 51 ms 12116 KB Output is correct
26 Correct 47 ms 12112 KB Output is correct
27 Correct 115 ms 22100 KB Output is correct
28 Correct 108 ms 22036 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 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
34 Halted 0 ms 0 KB -