제출 #50297

#제출 시각아이디문제언어결과실행 시간메모리
50297top34051철로 (IOI14_rail)C++17
8 / 100
121 ms24548 KiB
#include "rail.h" #include<bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5; int pos, ord[maxn]; int ban[maxn]; int rec[maxn][maxn]; int ask(int x, int y) { if(x>y) swap(x,y); if(!rec[x][y]) rec[x][y] = getDistance(x,y); return rec[x][y]; } int cmp(int x, int y) { return ask(0,x) < ask(0,y); } void findLocation(int N, int first, int location[], int stype[]) { //find right for(int i=1;i<N;i++) ord[i] = i; sort(&ord[1],&ord[N],cmp); int pos = ord[1]; for(int i=2;i<N;i++) { int x = ord[i]; if(ask(0,x)!=ask(pos,x)+ask(0,pos)) pos = x; } //solve ban[pos] = 1; location[pos] = first + ask(0,pos); stype[pos] = 2; while(1) { int x = -1; //nearest C for(int i=0;i<N;i++) { if(!ban[i] && (x==-1 || ask(pos,i)<ask(pos,x))) { x = i; } } if(x==-1) break; ban[x] = 1; location[x] = location[pos] - ask(pos,x); stype[x] = 1; // printf("%d (%d): ",x,location[x]); //sweep right for(int i=0;i<N;i++) { if(!ban[i] && ask(pos,i)-ask(pos,x)==ask(x,i)) { ban[i] = 1; location[i] = location[x] + ask(x,i); stype[i] = 2; // printf("%d (%d) ",i,location[i]); } } // printf("\n"); } // for(int i=0;i<N;i++) printf("%d %d\n",stype[i],location[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...