답안 #394898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394898 2021-04-27T12:46:01 Z irmuun 자매 도시 (APIO20_swap) C++17
37 / 100
2000 ms 8448 KB
#include "swap.h"
#include<bits/stdc++.h>
using namespace std;
int a,b,i,n,m,link[200000],edge[200000],sz[200000],x,y,ans[200000];
pair<int, pair<int,int> >p[200000];
int find(int x){
  if(link[x]==x){
    return x;
  }
  return link[x]=find(link[x]);
}
bool same(int a,int b){
  if(find(a)==find(b)){
    return true;
  }
  else{
    return false;
  }
}
void unite(int a,int b){
  a=find(a);
  b=find(b);
  if(sz[a]<sz[b]){
    swap(a,b);
  }
  if(ans[b]==1){
    ans[a]=1;
  }
  link[b]=a;
  sz[a]+=sz[b];
}
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
  m=M;
  n=N;
  for(i=0;i<M;i++){
    p[i].first=W[i];
    p[i].second.first=V[i];
    p[i].second.second=U[i];
  }
  sort(p,p+m);
}
int getMinimumFuelCapacity(int X, int Y) {
  for(i=0;i<n;i++){
    link[i]=i;
    sz[i]=1;
    edge[i]=0;
    ans[i]=0;
  }
  for(i=0;i<m;i++){
    x=p[i].second.first;
    y=p[i].second.second;
    edge[x]++;
    edge[y]++;
    if(find(x)==find(y)||edge[x]>2||edge[y]>2){
      ans[find(x)]=1;
      ans[find(y)]=1;
    }
    unite(x,y);
    if(find(X)==find(Y)&&ans[find(X)]==1){
      return p[i].first;
    }
  }
  return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 45 ms 4392 KB Output is correct
10 Correct 65 ms 5124 KB Output is correct
11 Correct 69 ms 5104 KB Output is correct
12 Correct 73 ms 5312 KB Output is correct
13 Correct 67 ms 5244 KB Output is correct
14 Execution timed out 2073 ms 4604 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 2058 ms 7272 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 316 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 45 ms 4392 KB Output is correct
11 Correct 65 ms 5124 KB Output is correct
12 Correct 69 ms 5104 KB Output is correct
13 Correct 73 ms 5312 KB Output is correct
14 Correct 67 ms 5244 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 ms 316 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 7 ms 1176 KB Output is correct
35 Correct 72 ms 5036 KB Output is correct
36 Correct 86 ms 5036 KB Output is correct
37 Correct 68 ms 4944 KB Output is correct
38 Correct 71 ms 5140 KB Output is correct
39 Correct 67 ms 5060 KB Output is correct
40 Correct 68 ms 4764 KB Output is correct
41 Correct 73 ms 5064 KB Output is correct
42 Correct 69 ms 5164 KB Output is correct
43 Correct 57 ms 5092 KB Output is correct
44 Correct 76 ms 4976 KB Output is correct
45 Correct 99 ms 6576 KB Output is correct
46 Correct 71 ms 5056 KB Output is correct
47 Correct 78 ms 5188 KB Output is correct
48 Correct 75 ms 5232 KB Output is correct
49 Correct 71 ms 6856 KB Output is correct
50 Correct 67 ms 5320 KB Output is correct
51 Correct 76 ms 5788 KB Output is correct
52 Correct 100 ms 6892 KB Output is correct
53 Correct 105 ms 7620 KB Output is correct
54 Correct 125 ms 8448 KB Output is correct
55 Correct 60 ms 5028 KB Output is correct
56 Correct 135 ms 7332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 45 ms 4392 KB Output is correct
10 Correct 65 ms 5124 KB Output is correct
11 Correct 69 ms 5104 KB Output is correct
12 Correct 73 ms 5312 KB Output is correct
13 Correct 67 ms 5244 KB Output is correct
14 Execution timed out 2073 ms 4604 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 45 ms 4392 KB Output is correct
11 Correct 65 ms 5124 KB Output is correct
12 Correct 69 ms 5104 KB Output is correct
13 Correct 73 ms 5312 KB Output is correct
14 Correct 67 ms 5244 KB Output is correct
15 Execution timed out 2073 ms 4604 KB Time limit exceeded
16 Halted 0 ms 0 KB -