답안 #1000316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000316 2024-06-17T08:34:24 Z codefox 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
152 ms 22104 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;
        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:60:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for (int j = 0; j < cyc.size()-1; j++)
      |                         ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 152 ms 22036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 152 ms 22036 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 118 ms 22024 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 56 ms 12040 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 424 KB Output is correct
20 Correct 29 ms 5772 KB Output is correct
21 Correct 117 ms 22096 KB Output is correct
22 Correct 112 ms 22076 KB Output is correct
23 Correct 127 ms 22100 KB Output is correct
24 Correct 123 ms 22104 KB Output is correct
25 Correct 49 ms 12052 KB Output is correct
26 Correct 47 ms 12116 KB Output is correct
27 Correct 117 ms 22100 KB Output is correct
28 Correct 120 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 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 344 KB Output is correct
2 Incorrect 0 ms 348 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 344 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 152 ms 22036 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 118 ms 22024 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 56 ms 12040 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 424 KB Output is correct
20 Correct 29 ms 5772 KB Output is correct
21 Correct 117 ms 22096 KB Output is correct
22 Correct 112 ms 22076 KB Output is correct
23 Correct 127 ms 22100 KB Output is correct
24 Correct 123 ms 22104 KB Output is correct
25 Correct 49 ms 12052 KB Output is correct
26 Correct 47 ms 12116 KB Output is correct
27 Correct 117 ms 22100 KB Output is correct
28 Correct 120 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 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 344 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 152 ms 22036 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 118 ms 22024 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 56 ms 12040 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 424 KB Output is correct
20 Correct 29 ms 5772 KB Output is correct
21 Correct 117 ms 22096 KB Output is correct
22 Correct 112 ms 22076 KB Output is correct
23 Correct 127 ms 22100 KB Output is correct
24 Correct 123 ms 22104 KB Output is correct
25 Correct 49 ms 12052 KB Output is correct
26 Correct 47 ms 12116 KB Output is correct
27 Correct 117 ms 22100 KB Output is correct
28 Correct 120 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 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -