답안 #977271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977271 2024-05-07T15:28:15 Z AliHasanli 슈퍼트리 잇기 (IOI20_supertrees) C++17
11 / 100
164 ms 22404 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int par[1001],siz[1001];
int findd(int a)
{
    if(a==par[a])return a;
    return par[a]=findd(par[a]);
}
bool unionn(int a,int b)
{
    a=findd(a),b=findd(b);
    if(a!=b)
    {
        if(siz[b]>siz[a])
            swap(a,b);
        par[b]=a;
        siz[a]+=siz[b];
        return 1;
    }
    return 0;
}
bool check(int a,int b)
{
    a=findd(a),b=findd(b);
    if(a!=b)return 1;
    return 0;
}
int construct(vector<vector<int>> p)
{
    for(int i=0;i<1001;i++)
    {
        par[i]=i;
        siz[i]=1;
    }
    int n = p.size();
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            if(p[i][j]==3)return 0;
	vector<vector<int>> answer;
	for (int i = 0; i < n; i++) {
		vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
	//for(int i=0;i<n-1;i++)
    //    for(int j=i+1;j<n;j++)
    //        if(p[i][j]==0 && !check(i,j))return 0;
	for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            if(p[i][j] && unionn(i,j)){answer[i][j]=1,answer[j][i]=1;break;}
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            if(p[i][j]==0 && !check(i,j))return 0;
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for(int i=0;i<n-1;i++)
      |     ^~~
supertrees.cpp:40:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |  vector<vector<int>> answer;
      |  ^~~~~~
supertrees.cpp:52:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |     for(int i=0;i<n-1;i++)
      |     ^~~
supertrees.cpp:55:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |  build(answer);
      |  ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 7 ms 1116 KB Output is correct
7 Correct 152 ms 22024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 7 ms 1116 KB Output is correct
7 Correct 152 ms 22024 KB Output is correct
8 Correct 0 ms 348 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 6 ms 1116 KB Output is correct
13 Correct 164 ms 22404 KB Output is correct
14 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 348 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 1 ms 348 KB Output is correct
3 Correct 1 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 7 ms 1116 KB Output is correct
7 Correct 152 ms 22024 KB Output is correct
8 Correct 0 ms 348 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 6 ms 1116 KB Output is correct
13 Correct 164 ms 22404 KB Output is correct
14 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 7 ms 1116 KB Output is correct
7 Correct 152 ms 22024 KB Output is correct
8 Correct 0 ms 348 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 6 ms 1116 KB Output is correct
13 Correct 164 ms 22404 KB Output is correct
14 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -