제출 #1018230

#제출 시각아이디문제언어결과실행 시간메모리
1018230Andrey철로 (IOI14_rail)C++14
0 / 100
49 ms600 KiB
#include "rail.h" #include<bits/stdc++.h> using namespace std; void findLocation(int n, int first, int location[], int stype[]) { location[0] = first; stype[0] = 1; vector<int> dis(n); int sm = INT_MAX,p = -1; for(int i = 1; i < n; i++) { dis[i] = getDistance(0,i); if(dis[i] < sm) { sm = dis[i]; p = i; } } location[p] = first+sm; stype[p] = 2; vector<pair<int,int>> a(0); vector<pair<int,int>> b(0); for(int i = 1; i < n; i++) { if(i != p) { cout << getDistance(p,i) << endl; if(getDistance(p,i) < dis[i]) { a.push_back({dis[i],i}); } else { b.push_back({dis[i],i}); } } } cout << a.size() << " " << b.size() << " " << p << endl; sort(a.begin(),a.end()); sort(b.begin(),b.end()); int p1 = -1; for(int i = 0; i < b.size(); i++) { if(p1 == -1 || getDistance(p1,b[i].second) >= dis[b[i].second]-dis[p1]) { location[b[i].second] = first+dis[b[i].second]; stype[b[i].second] = 2; p1 = b[i].second; } else { location[b[i].second] = first+2*dis[p1]-dis[b[i].second]; stype[b[i].second] = 1; } } p1 = -1; for(int i = 0; i < a.size(); i++) { if(p1 == -1 || getDistance(p1,a[i].second) >= dis[a[i].second]-dis[p1]) { location[a[i].second] = first-dis[a[i].second]+2*dis[p]; stype[a[i].second] = 1; p1 = a[i].second; } else { location[a[i].second] = first+2*dis[p]-(2*dis[p1]-dis[a[i].second]); stype[a[i].second] = 2; } } for(int i = 0; i < n; i++) { cout << location[i] << " "; } cout << endl; for(int i = 0; i < n; i++) { cout << stype[i] << " "; } cout << endl; }

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

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