Submission #403394

# Submission time Handle Problem Language Result Execution time Memory
403394 2021-05-13T06:41:50 Z Wasrek Swapping Cities (APIO20_swap) C++14
0 / 100
4 ms 5120 KB
#include<bits/stdc++.h>
#include "swap.h"
#include <vector>
#define SIZE 100010
using namespace std;
struct A{
  int u,w;
};
int sub2=1,m1=2e9,m2=2e9,m3=2e9;
vector<A> g[SIZE];

void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    for(int i=0;i<M;i++){
      g[U[i]].push_back({V[i],W[i]});
      g[V[i]].push_back({U[i],W[i]});
      if(U[i]!=0) sub2=0;
      if(W[i]<m1){
        m3=m2,m2=m1,m1=V[i];
      }else if(W[i]<m2){
        m3=m2,m2=V[i];
      }else if(W[i]<m3){
        m3=V[i];
      }
    }
}

int getMinimumFuelCapacity(int X, int Y) {
  //min path ที่มี node อยู่ระหว่าง path
  //หา min ถนนที่เชื่อมกับโหนดตรงกลาง
  //เทียบ min กับ path อื่นๆ ไปได้ (เชื่อมตรงเลยก็ได้)
  if(sub2){
    if(X==0 || Y==0) return -1;
    if(X!=m1 && Y!=m1){
      return max(g[X][0].w,max(g[Y][0].w,g[m1][0].w));
    }else if(X!=m2 && Y!=m2){
      return max(g[X][0].w,max(g[Y][0].w,g[m2][0].w));
    }else if(X!=m3 && Y!=m3){
      return max(g[X][0].w,max(g[Y][0].w,g[m3][0].w));
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Runtime error 4 ms 5120 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Runtime error 4 ms 5120 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Runtime error 4 ms 5120 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Runtime error 4 ms 5120 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Runtime error 4 ms 5120 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Runtime error 4 ms 5120 KB Execution killed with signal 11