제출 #795627

#제출 시각아이디문제언어결과실행 시간메모리
795627medmdg철로 (IOI14_rail)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #pragma once #include "rail.h" using ll =long long; ll LINF=1000000000000000000; int INF=1000000000; #define pi pair<int,int> #define pl pair<ll,ll> #define endl '\n' #define vi vector<int> #define vii vector<vector<int>> #define vl vector<ll> #define vll vector<vector<ll>> using namespace std; int minind(vi &v){ int mn=v[0]; int m=0; for(int i=1;i<v.size();i++){ if(v[i]<mn){ mn=v[i]; m=i; } } return m; } int getDistance(int i, int j); void findLocation(int n, int first, int location[], int stype[]){ for(int i=0;i<n;i++){ location[i]=0; stype[i]=0; } vi d0(n),ds(n); for(int i=1;i<n;i++){ d0[i]= getDistance(0,i); } d0[0]=INF; int second=minind(d0); d0[0]=0; for(int i=1;i<n;i++){ if(i==second)continue; int dist= getDistance(i,second); ds[i]=dist; } stype[0]=1; stype[second]=2; location[0]=first; location[second]=first+d0[second]; vector<pi>right,left; for(int i=0;i<n;i++){ if(stype[i])continue; if(d0[i]>ds[i]){ left.push_back(make_pair(ds[i],i)); } else right.push_back(make_pair(d0[i],i)); } std::sort(right.begin(), right.end()); std::sort(left.begin(), left.end()); int last=second,lasto=0; for(auto p:right){ int i=p.second; int dist=0; if(lasto==0) dist= getDistance(i,last); else dist=getDistance(i,lasto); if((d0[i]>dist&&lasto==0)||(lasto&&dist+location[lasto]-first!=d0[i])){ stype[i]=1; location[i]= location[last]-dist; } else{ stype[i]=2; location[i]=first+d0[i]; last=i; } } if(left.size()){ last = left[0].second; stype[last]=1; location[last]=location[second]-ds[last]; } lasto=2; for( auto p:left){ int i=p.second; if(i==last)continue; if(lasto==2) dist= getDistance(i,last); else dist=getDistance(i,lasto); if((ds[i]>dist&&lasto==0)||(lasto&&dist-location[lasto]+second!=ds[i])){ stype[i]=2; location[i]=location[last]+dist; } else { stype[i]=1; location[i]=location[second]-ds[i]; last=i; } } }

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

rail.cpp:2:9: warning: #pragma once in main file
    2 | #pragma once
      |         ^~~~
rail.cpp: In function 'int minind(std::vector<int>&)':
rail.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i=1;i<v.size();i++){
      |                 ~^~~~~~~~~
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:89:12: error: 'dist' was not declared in this scope
   89 |            dist= getDistance(i,last);
      |            ^~~~
rail.cpp:91:12: error: 'dist' was not declared in this scope
   91 |            dist=getDistance(i,lasto);
      |            ^~~~
rail.cpp:92:19: error: 'dist' was not declared in this scope
   92 |         if((ds[i]>dist&&lasto==0)||(lasto&&dist-location[lasto]+second!=ds[i])){
      |                   ^~~~