# | 제출 시각^{} |
아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|

314065 | 2020-10-18T05:13:08 Z | linear00000 | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 263 ms | 22392 KB |

#include "supertrees.h" #include <bits/stdc++.h> using namespace std; vector<vector<int> > d; vector<int> C[1004]; int par[1004], num = 0; int findpar(int N) { if (N == par[N]) return N; else return par[N] = findpar(par[N]); } void merge(int a, int b) { int aa = findpar(a), bb = findpar(b); par[aa] = bb; } int construct(vector<vector<int> > v) { int n = v.size(); for (int i = 0; i < n; i++) par[i] = i; d.resize(n); for (int i = 0; i < n; i++) d[i].resize(n); // checking int type = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (v[i][j] == 2) { type = 2; break; } if (v[i][j] == 1) type = 1; } if (type == 2) break; } // checking ends for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 2 && i != j) merge(i, j); } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 0) { if (findpar(i) == findpar(j)) return 0; } } } for (int i = 0; i < n; i++) par[i] = findpar(i); for (int i = 0; i < n; i++) C[par[i]].push_back(i); for (int i = 0; i < n; i++) { int cnt = 0; if (C[i].size() == 2) return 0; else if (C[i].size() >= 3) { for (int j = 0; j < C[i].size() - 1; j++) { d[C[i][j]][C[i][j + 1]] = 1, d[C[i][j + 1]][C[i][j]] = 1; } d[C[i][C[i].size() - 1]][C[i][0]] = 1, d[C[i][0]][C[i][C[i].size() - 1]] = 1; } } for (int i=0; i<n; i++) par[i] = i, C[i].clear(); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 1 && i != j) merge(i, j); } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 0) { if (findpar(i) == findpar(j)) return 0; } } } for (int i = 0; i < n; i++) par[i] = findpar(i); for (int i = 0; i < n; i++) C[par[i]].push_back(i); for (int i = 0; i < n; i++) { for (int j = 0; j < C[i].size(); j++) { if (C[i][j] != i) d[i][C[i][j]] = 1, d[C[i][j]][i] = 1; } } build(d); return 1; }

### Compilation message

# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 384 KB | Output is correct |

2 | Correct | 0 ms | 384 KB | Output is correct |

3 | Correct | 0 ms | 384 KB | Output is correct |

4 | Correct | 1 ms | 384 KB | Output is correct |

5 | Correct | 0 ms | 384 KB | Output is correct |

6 | Correct | 10 ms | 1280 KB | Output is correct |

7 | Correct | 237 ms | 22284 KB | Output is correct |

# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 384 KB | Output is correct |

2 | Correct | 0 ms | 384 KB | Output is correct |

3 | Correct | 0 ms | 384 KB | Output is correct |

4 | Correct | 1 ms | 384 KB | Output is correct |

5 | Correct | 0 ms | 384 KB | Output is correct |

6 | Correct | 10 ms | 1280 KB | Output is correct |

7 | Correct | 237 ms | 22284 KB | Output is correct |

8 | Correct | 0 ms | 384 KB | Output is correct |

9 | Correct | 0 ms | 384 KB | Output is correct |

10 | Correct | 1 ms | 384 KB | Output is correct |

11 | Correct | 0 ms | 384 KB | Output is correct |

12 | Correct | 10 ms | 1280 KB | Output is correct |

13 | Correct | 238 ms | 22264 KB | Output is correct |

14 | Correct | 1 ms | 384 KB | Output is correct |

15 | Correct | 0 ms | 384 KB | Output is correct |

16 | Correct | 5 ms | 768 KB | Output is correct |

17 | Correct | 116 ms | 12276 KB | Output is correct |

18 | Correct | 1 ms | 384 KB | Output is correct |

19 | Correct | 0 ms | 384 KB | Output is correct |

20 | Correct | 59 ms | 5864 KB | Output is correct |

21 | Correct | 236 ms | 22136 KB | Output is correct |

22 | Correct | 263 ms | 22136 KB | Output is correct |

23 | Correct | 247 ms | 22136 KB | Output is correct |

24 | Correct | 234 ms | 22392 KB | Output is correct |

25 | Correct | 101 ms | 12280 KB | Output is correct |

26 | Correct | 119 ms | 12152 KB | Output is correct |

27 | Correct | 245 ms | 22136 KB | Output is correct |

28 | Correct | 238 ms | 22136 KB | Output is correct |

# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|

1 | Correct | 1 ms | 384 KB | Output is correct |

2 | Correct | 1 ms | 384 KB | Output is correct |

3 | Correct | 0 ms | 384 KB | Output is correct |

4 | Correct | 0 ms | 384 KB | Output is correct |

5 | Correct | 0 ms | 384 KB | Output is correct |

6 | Correct | 1 ms | 384 KB | Output is correct |

7 | Correct | 0 ms | 384 KB | Output is correct |

8 | Correct | 11 ms | 1280 KB | Output is correct |

9 | Correct | 246 ms | 22136 KB | Output is correct |

10 | Correct | 1 ms | 384 KB | Output is correct |

11 | Correct | 1 ms | 384 KB | Output is correct |

12 | Correct | 12 ms | 1280 KB | Output is correct |

13 | Correct | 235 ms | 22136 KB | Output is correct |

14 | Correct | 1 ms | 384 KB | Output is correct |

15 | Correct | 0 ms | 384 KB | Output is correct |

16 | Correct | 5 ms | 768 KB | Output is correct |

17 | Correct | 110 ms | 12152 KB | Output is correct |

18 | Correct | 1 ms | 384 KB | Output is correct |

19 | Correct | 1 ms | 384 KB | Output is correct |

20 | Correct | 1 ms | 384 KB | Output is correct |

21 | Correct | 59 ms | 5896 KB | Output is correct |

22 | Correct | 236 ms | 22136 KB | Output is correct |

23 | Correct | 237 ms | 22136 KB | Output is correct |

24 | Correct | 244 ms | 22136 KB | Output is correct |

25 | Correct | 102 ms | 12272 KB | Output is correct |

26 | Correct | 99 ms | 12152 KB | Output is correct |

27 | Correct | 237 ms | 22136 KB | Output is correct |

28 | Correct | 250 ms | 22136 KB | Output is correct |

29 | Correct | 101 ms | 12152 KB | Output is correct |

# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|

1 | Correct | 1 ms | 384 KB | Output is correct |

2 | Correct | 1 ms | 384 KB | Output is correct |

3 | Correct | 0 ms | 384 KB | Output is correct |

4 | Correct | 62 ms | 5880 KB | Output is correct |

5 | Correct | 238 ms | 22256 KB | Output is correct |

6 | Correct | 233 ms | 22136 KB | Output is correct |

7 | Correct | 247 ms | 22264 KB | Output is correct |

8 | Correct | 0 ms | 384 KB | Output is correct |

9 | Correct | 59 ms | 5880 KB | Output is correct |

10 | Correct | 241 ms | 22168 KB | Output is correct |

11 | Correct | 240 ms | 22136 KB | Output is correct |

12 | Correct | 251 ms | 22136 KB | Output is correct |

13 | Correct | 1 ms | 384 KB | Output is correct |

14 | Correct | 0 ms | 384 KB | Output is correct |

15 | Incorrect | 0 ms | 384 KB | Too many ways to get from 0 to 4, should be 1 found no less than 2 |

16 | Halted | 0 ms | 0 KB | - |

# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 384 KB | Output is correct |

2 | Correct | 0 ms | 384 KB | Output is correct |

3 | Correct | 0 ms | 384 KB | Output is correct |

4 | Correct | 1 ms | 384 KB | Output is correct |

5 | Correct | 0 ms | 384 KB | Output is correct |

6 | Correct | 10 ms | 1280 KB | Output is correct |

7 | Correct | 237 ms | 22284 KB | Output is correct |

8 | Correct | 0 ms | 384 KB | Output is correct |

9 | Correct | 0 ms | 384 KB | Output is correct |

10 | Correct | 1 ms | 384 KB | Output is correct |

11 | Correct | 0 ms | 384 KB | Output is correct |

12 | Correct | 10 ms | 1280 KB | Output is correct |

13 | Correct | 238 ms | 22264 KB | Output is correct |

14 | Correct | 1 ms | 384 KB | Output is correct |

15 | Correct | 0 ms | 384 KB | Output is correct |

16 | Correct | 5 ms | 768 KB | Output is correct |

17 | Correct | 116 ms | 12276 KB | Output is correct |

18 | Correct | 1 ms | 384 KB | Output is correct |

19 | Correct | 0 ms | 384 KB | Output is correct |

20 | Correct | 59 ms | 5864 KB | Output is correct |

21 | Correct | 236 ms | 22136 KB | Output is correct |

22 | Correct | 263 ms | 22136 KB | Output is correct |

23 | Correct | 247 ms | 22136 KB | Output is correct |

24 | Correct | 234 ms | 22392 KB | Output is correct |

25 | Correct | 101 ms | 12280 KB | Output is correct |

26 | Correct | 119 ms | 12152 KB | Output is correct |

27 | Correct | 245 ms | 22136 KB | Output is correct |

28 | Correct | 238 ms | 22136 KB | Output is correct |

29 | Correct | 1 ms | 384 KB | Output is correct |

30 | Correct | 1 ms | 384 KB | Output is correct |

31 | Correct | 0 ms | 384 KB | Output is correct |

32 | Correct | 0 ms | 384 KB | Output is correct |

33 | Correct | 0 ms | 384 KB | Output is correct |

34 | Correct | 1 ms | 384 KB | Output is correct |

35 | Correct | 0 ms | 384 KB | Output is correct |

36 | Correct | 11 ms | 1280 KB | Output is correct |

37 | Correct | 246 ms | 22136 KB | Output is correct |

38 | Correct | 1 ms | 384 KB | Output is correct |

39 | Correct | 1 ms | 384 KB | Output is correct |

40 | Correct | 12 ms | 1280 KB | Output is correct |

41 | Correct | 235 ms | 22136 KB | Output is correct |

42 | Correct | 1 ms | 384 KB | Output is correct |

43 | Correct | 0 ms | 384 KB | Output is correct |

44 | Correct | 5 ms | 768 KB | Output is correct |

45 | Correct | 110 ms | 12152 KB | Output is correct |

46 | Correct | 1 ms | 384 KB | Output is correct |

47 | Correct | 1 ms | 384 KB | Output is correct |

48 | Correct | 1 ms | 384 KB | Output is correct |

49 | Correct | 59 ms | 5896 KB | Output is correct |

50 | Correct | 236 ms | 22136 KB | Output is correct |

51 | Correct | 237 ms | 22136 KB | Output is correct |

52 | Correct | 244 ms | 22136 KB | Output is correct |

53 | Correct | 102 ms | 12272 KB | Output is correct |

54 | Correct | 99 ms | 12152 KB | Output is correct |

55 | Correct | 237 ms | 22136 KB | Output is correct |

56 | Correct | 250 ms | 22136 KB | Output is correct |

57 | Correct | 101 ms | 12152 KB | Output is correct |

58 | Correct | 1 ms | 384 KB | Output is correct |

59 | Correct | 1 ms | 384 KB | Output is correct |

60 | Correct | 5 ms | 768 KB | Output is correct |

61 | Correct | 106 ms | 12144 KB | Output is correct |

62 | Correct | 1 ms | 384 KB | Output is correct |

63 | Correct | 0 ms | 384 KB | Output is correct |

64 | Correct | 1 ms | 384 KB | Output is correct |

65 | Incorrect | 60 ms | 5880 KB | Too many ways to get from 1 to 477, should be 2 found no less than 3 |

66 | Halted | 0 ms | 0 KB | - |

# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|

1 | Correct | 0 ms | 384 KB | Output is correct |

2 | Correct | 0 ms | 384 KB | Output is correct |

3 | Correct | 0 ms | 384 KB | Output is correct |

4 | Correct | 1 ms | 384 KB | Output is correct |

5 | Correct | 0 ms | 384 KB | Output is correct |

6 | Correct | 10 ms | 1280 KB | Output is correct |

7 | Correct | 237 ms | 22284 KB | Output is correct |

8 | Correct | 0 ms | 384 KB | Output is correct |

9 | Correct | 0 ms | 384 KB | Output is correct |

10 | Correct | 1 ms | 384 KB | Output is correct |

11 | Correct | 0 ms | 384 KB | Output is correct |

12 | Correct | 10 ms | 1280 KB | Output is correct |

13 | Correct | 238 ms | 22264 KB | Output is correct |

14 | Correct | 1 ms | 384 KB | Output is correct |

15 | Correct | 0 ms | 384 KB | Output is correct |

16 | Correct | 5 ms | 768 KB | Output is correct |

17 | Correct | 116 ms | 12276 KB | Output is correct |

18 | Correct | 1 ms | 384 KB | Output is correct |

19 | Correct | 0 ms | 384 KB | Output is correct |

20 | Correct | 59 ms | 5864 KB | Output is correct |

21 | Correct | 236 ms | 22136 KB | Output is correct |

22 | Correct | 263 ms | 22136 KB | Output is correct |

23 | Correct | 247 ms | 22136 KB | Output is correct |

24 | Correct | 234 ms | 22392 KB | Output is correct |

25 | Correct | 101 ms | 12280 KB | Output is correct |

26 | Correct | 119 ms | 12152 KB | Output is correct |

27 | Correct | 245 ms | 22136 KB | Output is correct |

28 | Correct | 238 ms | 22136 KB | Output is correct |

29 | Correct | 1 ms | 384 KB | Output is correct |

30 | Correct | 1 ms | 384 KB | Output is correct |

31 | Correct | 0 ms | 384 KB | Output is correct |

32 | Correct | 0 ms | 384 KB | Output is correct |

33 | Correct | 0 ms | 384 KB | Output is correct |

34 | Correct | 1 ms | 384 KB | Output is correct |

35 | Correct | 0 ms | 384 KB | Output is correct |

36 | Correct | 11 ms | 1280 KB | Output is correct |

37 | Correct | 246 ms | 22136 KB | Output is correct |

38 | Correct | 1 ms | 384 KB | Output is correct |

39 | Correct | 1 ms | 384 KB | Output is correct |

40 | Correct | 12 ms | 1280 KB | Output is correct |

41 | Correct | 235 ms | 22136 KB | Output is correct |

42 | Correct | 1 ms | 384 KB | Output is correct |

43 | Correct | 0 ms | 384 KB | Output is correct |

44 | Correct | 5 ms | 768 KB | Output is correct |

45 | Correct | 110 ms | 12152 KB | Output is correct |

46 | Correct | 1 ms | 384 KB | Output is correct |

47 | Correct | 1 ms | 384 KB | Output is correct |

48 | Correct | 1 ms | 384 KB | Output is correct |

49 | Correct | 59 ms | 5896 KB | Output is correct |

50 | Correct | 236 ms | 22136 KB | Output is correct |

51 | Correct | 237 ms | 22136 KB | Output is correct |

52 | Correct | 244 ms | 22136 KB | Output is correct |

53 | Correct | 102 ms | 12272 KB | Output is correct |

54 | Correct | 99 ms | 12152 KB | Output is correct |

55 | Correct | 237 ms | 22136 KB | Output is correct |

56 | Correct | 250 ms | 22136 KB | Output is correct |

57 | Correct | 101 ms | 12152 KB | Output is correct |

58 | Correct | 1 ms | 384 KB | Output is correct |

59 | Correct | 1 ms | 384 KB | Output is correct |

60 | Correct | 0 ms | 384 KB | Output is correct |

61 | Correct | 62 ms | 5880 KB | Output is correct |

62 | Correct | 238 ms | 22256 KB | Output is correct |

63 | Correct | 233 ms | 22136 KB | Output is correct |

64 | Correct | 247 ms | 22264 KB | Output is correct |

65 | Correct | 0 ms | 384 KB | Output is correct |

66 | Correct | 59 ms | 5880 KB | Output is correct |

67 | Correct | 241 ms | 22168 KB | Output is correct |

68 | Correct | 240 ms | 22136 KB | Output is correct |

69 | Correct | 251 ms | 22136 KB | Output is correct |

70 | Correct | 1 ms | 384 KB | Output is correct |

71 | Correct | 0 ms | 384 KB | Output is correct |

72 | Incorrect | 0 ms | 384 KB | Too many ways to get from 0 to 4, should be 1 found no less than 2 |

73 | Halted | 0 ms | 0 KB | - |