Submission #864740

# Submission time Handle Problem Language Result Execution time Memory
864740 2023-10-23T14:07:45 Z andrei_boaca Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
164 ms 32084 KB
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;

int n;
vector<vector<int>> adj;
vector<int> muchii[1005];
int comp[1005],nrcomp;
vector<int> nodes;
void dfs(int nod)
{
    comp[nod]=nrcomp;
    nodes.push_back(nod);
    for(int i:muchii[nod])
        if(!comp[i])
            dfs(i);
}
int construct(std::vector<std::vector<int>> p)
{
    n=p.size();
    adj.resize(n);
    for(int i=0;i<n;i++)
        adj[i].resize(n);
    bool sub1=1;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            sub1&=(p[i][j]<=1);
    if(sub1)
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(p[i][j]==1)
                {
                    muchii[i].push_back(j);
                    muchii[j].push_back(i);
                }
        for(int i=0;i<n;i++)
            if(comp[i]==0)
            {
                nrcomp++;
                nodes.clear();
                dfs(i);
                for(int j=1;j<nodes.size();j++)
                {
                    int a=nodes[j-1];
                    int b=nodes[j];
                    adj[a][b]=adj[b][a]=1;
                }
            }
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            {
                if(p[i][j]==0&&comp[i]==comp[j])
                    return 0;
                if(p[i][j]==1&&comp[i]!=comp[j])
                    return 0;
            }
        build(adj);
        return 1;
    }
	return 0;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:45:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |                 for(int j=1;j<nodes.size();j++)
      |                             ~^~~~~~~~~~~~~
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1624 KB Output is correct
7 Correct 164 ms 32084 KB Output is correct
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1624 KB Output is correct
7 Correct 164 ms 32084 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 360 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 7 ms 1372 KB Output is correct
13 Correct 152 ms 24488 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 1116 KB Output is correct
17 Correct 75 ms 19992 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 37 ms 6492 KB Output is correct
21 Correct 149 ms 25168 KB Output is correct
22 Correct 147 ms 24208 KB Output is correct
23 Correct 163 ms 28236 KB Output is correct
24 Correct 150 ms 24100 KB Output is correct
25 Correct 64 ms 15184 KB Output is correct
26 Correct 62 ms 14164 KB Output is correct
27 Correct 157 ms 30228 KB Output is correct
28 Correct 149 ms 24144 KB Output is correct
# Verdict Execution time Memory 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 Answer gives possible 0 while actual possible 1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1624 KB Output is correct
7 Correct 164 ms 32084 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 360 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 7 ms 1372 KB Output is correct
13 Correct 152 ms 24488 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 1116 KB Output is correct
17 Correct 75 ms 19992 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 37 ms 6492 KB Output is correct
21 Correct 149 ms 25168 KB Output is correct
22 Correct 147 ms 24208 KB Output is correct
23 Correct 163 ms 28236 KB Output is correct
24 Correct 150 ms 24100 KB Output is correct
25 Correct 64 ms 15184 KB Output is correct
26 Correct 62 ms 14164 KB Output is correct
27 Correct 157 ms 30228 KB Output is correct
28 Correct 149 ms 24144 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 Answer gives possible 0 while actual possible 1
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1624 KB Output is correct
7 Correct 164 ms 32084 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 360 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 7 ms 1372 KB Output is correct
13 Correct 152 ms 24488 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 1116 KB Output is correct
17 Correct 75 ms 19992 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 37 ms 6492 KB Output is correct
21 Correct 149 ms 25168 KB Output is correct
22 Correct 147 ms 24208 KB Output is correct
23 Correct 163 ms 28236 KB Output is correct
24 Correct 150 ms 24100 KB Output is correct
25 Correct 64 ms 15184 KB Output is correct
26 Correct 62 ms 14164 KB Output is correct
27 Correct 157 ms 30228 KB Output is correct
28 Correct 149 ms 24144 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 Answer gives possible 0 while actual possible 1
34 Halted 0 ms 0 KB -