제출 #587868

#제출 시각아이디문제언어결과실행 시간메모리
587868FatihSolak철로 (IOI14_rail)C++17
30 / 100
82 ms12296 KiB
#include "rail.h" #include <bits/stdc++.h> #define N 5005 using namespace std; int d[N][N]; int get(int i,int j){ if(i > j)swap(i,j); if(i == j)return 0; if(d[i][j]) return d[i][j]; return d[i][j] = getDistance(i,j); } void findLocation(int n, int first, int location[], int stype[]) { for(int i = 0;i<n;i++){ location[i] = -1; stype[i] = -1; } location[0] = first; stype[0] = 1; if(n == 1)return; vector<pair<int,int>> v; for(int i = 0;i<n;i++){ if(i == 0)continue; v.push_back({get(0,i),i}); } sort(v.begin(),v.end()); int last = v[0].second; int x = last; location[last] = v[0].first + first; stype[last] = 2; int delta = 1e9; for(int i = 0;i<n;i++){ if(i == x)continue; delta = min(delta,get(x,i)); } for(int i = 1;i<v.size();i++){ if(get(x,v[i].second) - 2*delta == get(0,v[i].second) - get(0,x)){ last = v[i].second; location[last] = v[i].first + first; stype[last] = 2; } } // for(int i = 0;i<n;i++){ // cout << location[i] << " " << stype[i] << endl; // } // cout << endl; v.clear(); for(int i = 0;i<n;i++){ if(i == last)continue; v.push_back({get(last,i),i}); } sort(v.begin(),v.end()); int frst = v[0].second; location[frst] = location[last]-v[0].first; stype[frst] = 1; for(int i = 1;i<v.size();i++){ if(stype[v[i].second] == 2)continue; //cout << frst << endl; //cout << (get(last,v[i].second) <= location[last] - first) << endl; //cout << get(last,v[i].second) - (location[last] - first) << " " << get(0,v[i].second) - 2*location[x] + 2*first << endl; //cout << get(0,v[i].second) << endl; if(get(last,v[i].second) <= location[last] - first || get(last,v[i].second) - (location[last] - first) == get(0,v[i].second) - 2*location[x] + 2*first ){ frst = v[i].second; location[frst] = location[last]-v[i].first; stype[frst] = 1; } } // for(int i = 0;i<n;i++){ // cout << location[i] << " " << stype[i] << endl; // } }

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 1;i<v.size();i++){
      |                   ~^~~~~~~~~
rail.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i = 1;i<v.size();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...