Submission #1000312

# Submission time Handle Problem Language Result Execution time Memory
1000312 2024-06-17T08:30:52 Z codefox Connecting Supertrees (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;
            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;
                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: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++)
      |                         ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 121 ms 22072 KB Output is correct
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 121 ms 22072 KB Output is correct
8 Correct 0 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 348 KB Output is correct
12 Correct 5 ms 1112 KB Output is correct
13 Correct 124 ms 22036 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 59 ms 12040 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 34 ms 5740 KB Output is correct
21 Correct 120 ms 22100 KB Output is correct
22 Correct 118 ms 22040 KB Output is correct
23 Correct 131 ms 22024 KB Output is correct
24 Correct 116 ms 22104 KB Output is correct
25 Correct 49 ms 12116 KB Output is correct
26 Correct 56 ms 12056 KB Output is correct
27 Correct 125 ms 22100 KB Output is correct
28 Correct 152 ms 22100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 121 ms 22072 KB Output is correct
8 Correct 0 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 348 KB Output is correct
12 Correct 5 ms 1112 KB Output is correct
13 Correct 124 ms 22036 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 59 ms 12040 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 34 ms 5740 KB Output is correct
21 Correct 120 ms 22100 KB Output is correct
22 Correct 118 ms 22040 KB Output is correct
23 Correct 131 ms 22024 KB Output is correct
24 Correct 116 ms 22104 KB Output is correct
25 Correct 49 ms 12116 KB Output is correct
26 Correct 56 ms 12056 KB Output is correct
27 Correct 125 ms 22100 KB Output is correct
28 Correct 152 ms 22100 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 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 -
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 121 ms 22072 KB Output is correct
8 Correct 0 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 348 KB Output is correct
12 Correct 5 ms 1112 KB Output is correct
13 Correct 124 ms 22036 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 59 ms 12040 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 34 ms 5740 KB Output is correct
21 Correct 120 ms 22100 KB Output is correct
22 Correct 118 ms 22040 KB Output is correct
23 Correct 131 ms 22024 KB Output is correct
24 Correct 116 ms 22104 KB Output is correct
25 Correct 49 ms 12116 KB Output is correct
26 Correct 56 ms 12056 KB Output is correct
27 Correct 125 ms 22100 KB Output is correct
28 Correct 152 ms 22100 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 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 -