답안 #1000309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000309 2024-06-17T08:29:09 Z codefox 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
129 ms 24196 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;
            if (vis[j]) return 0;
            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;
                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 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 Correct 0 ms 344 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 124 ms 24072 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 Correct 0 ms 344 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 124 ms 24072 KB Output is correct
8 Correct 1 ms 348 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 432 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 115 ms 23936 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 56 ms 14200 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 29 ms 6352 KB Output is correct
21 Correct 117 ms 23892 KB Output is correct
22 Correct 116 ms 24148 KB Output is correct
23 Correct 129 ms 24148 KB Output is correct
24 Correct 111 ms 24144 KB Output is correct
25 Correct 51 ms 14216 KB Output is correct
26 Correct 47 ms 14164 KB Output is correct
27 Correct 122 ms 24196 KB Output is correct
28 Correct 112 ms 23888 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 432 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 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 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 Correct 0 ms 344 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 124 ms 24072 KB Output is correct
8 Correct 1 ms 348 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 432 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 115 ms 23936 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 56 ms 14200 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 29 ms 6352 KB Output is correct
21 Correct 117 ms 23892 KB Output is correct
22 Correct 116 ms 24148 KB Output is correct
23 Correct 129 ms 24148 KB Output is correct
24 Correct 111 ms 24144 KB Output is correct
25 Correct 51 ms 14216 KB Output is correct
26 Correct 47 ms 14164 KB Output is correct
27 Correct 122 ms 24196 KB Output is correct
28 Correct 112 ms 23888 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 432 KB Answer gives possible 1 while actual possible 0
33 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 124 ms 24072 KB Output is correct
8 Correct 1 ms 348 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 432 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 115 ms 23936 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 56 ms 14200 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 29 ms 6352 KB Output is correct
21 Correct 117 ms 23892 KB Output is correct
22 Correct 116 ms 24148 KB Output is correct
23 Correct 129 ms 24148 KB Output is correct
24 Correct 111 ms 24144 KB Output is correct
25 Correct 51 ms 14216 KB Output is correct
26 Correct 47 ms 14164 KB Output is correct
27 Correct 122 ms 24196 KB Output is correct
28 Correct 112 ms 23888 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 432 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -