Submission #1134157

#TimeUsernameProblemLanguageResultExecution timeMemory
1134157Ak_16Rail (IOI14_rail)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int dis1[10000]; int sp; int dis2[10000]; int sta[10000]; int mnd; struct pla{ int x, int y; } vector<pla> lef,don,rig; bool cmp1(const pla &a, const pla&b){ return a.y > b.y; } bool cmp2(const pla &a, const pla&b){ return a.y < b.y; } void findLocation(int n, int first, int loc[], int stype[]){ loc[0] = first; stype[0]=1; sp = 0; sta[0] = 2; mnd = 100000000; for(int i=1; i<n; i++){ dis1[i] = getDistance(0, i); if(dis1[i]<mnd){sp = i; mnd = dis1[i];} } loc[sp] = first + dis1[sp]; stype[sp]=2; sta[sp] = 2; mnd = 100000000; for(int i=1; i<n; i++){ if(i!=sp){ dis2[i] = getDistance(sp, i); if(dis1[i] == dis2[i] + dis1[sp]){ if(dis2[i]<dis1[sp]){sta[i] = 2; loc[i] = loc[sp] - dis2[i]; stype[i] = 1;} else {sta[i] = 1;} } else {sta[i] = 3;} } } for(int i=1; i<n; i++){ if(sta[i]==1){ lef.push_back(i, dis2[i]); } if(sta[i]==3){ rig.push_back(i, dis1[i]); } } sort(rig.begin(), rig.end(), cmp2); sort(lef.begin(), lef.end(), cmp2); int cur = sp; for(const &auto inf : rig){ int n1 = inf.x; int n2 = inf.y; if(cur==sp){ loc[n1] = first + n2; stype[n1] = 2; cur = n1; } else { int n3 = getDistance(cur, n1); if(n2 == n3 + dis1[cur]){ loc[n1] = loc[cur] - n3; stype[n1] = 1; } else { loc[n1] = first + n2; stype[n1] = 2; cur = n1; } } } cur = 0; for(const &auto inf : lef){ int n1 = inf.x; int n2 = inf.y; if(cur==0){ loc[n1] = loc[sp] - n2; stype[n1] = 1; cur = n1; } else { int n3 = getDistance(cur, n1); if(n2 == n3 + dis1[cur]){ loc[n1] = loc[cur] + n3; stype[n1] = 2; } else { loc[n1] = loc[sp] - n2; stype[n1] = 1; cur = n1; } } } }

Compilation message (stderr)

rail.cpp:14:10: error: expected unqualified-id before 'int'
   14 |   int x, int y;
      |          ^~~
rail.cpp:17:13: error: invalid declarator before 'lef'
   17 | vector<pla> lef,don,rig;
      |             ^~~
rail.cpp: In function 'bool cmp1(const pla&, const pla&)':
rail.cpp:20:12: error: 'const struct pla' has no member named 'y'
   20 |   return a.y > b.y;
      |            ^
rail.cpp:20:18: error: 'const struct pla' has no member named 'y'
   20 |   return a.y > b.y;
      |                  ^
rail.cpp: In function 'bool cmp2(const pla&, const pla&)':
rail.cpp:24:12: error: 'const struct pla' has no member named 'y'
   24 |   return a.y < b.y;
      |            ^
rail.cpp:24:18: error: 'const struct pla' has no member named 'y'
   24 |   return a.y < b.y;
      |                  ^
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:36:15: error: 'getDistance' was not declared in this scope
   36 |     dis1[i] = getDistance(0, i);
      |               ^~~~~~~~~~~
rail.cpp:51:17: error: 'getDistance' was not declared in this scope
   51 |       dis2[i] = getDistance(sp, i);
      |                 ^~~~~~~~~~~
rail.cpp:65:7: error: 'lef' was not declared in this scope
   65 |       lef.push_back(i, dis2[i]);
      |       ^~~
rail.cpp:68:7: error: 'rig' was not declared in this scope
   68 |       rig.push_back(i, dis1[i]);
      |       ^~~
rail.cpp:72:8: error: 'rig' was not declared in this scope
   72 |   sort(rig.begin(), rig.end(), cmp2);
      |        ^~~
rail.cpp:73:8: error: 'lef' was not declared in this scope
   73 |   sort(lef.begin(), lef.end(), cmp2);
      |        ^~~
rail.cpp:76:14: error: expected unqualified-id before 'auto'
   76 |   for(const &auto inf : rig){
      |              ^~~~
rail.cpp:76:14: error: expected ';' before 'auto'
   76 |   for(const &auto inf : rig){
      |              ^~~~
      |              ;
rail.cpp:76:23: error: found ':' in nested-name-specifier, expected '::'
   76 |   for(const &auto inf : rig){
      |                       ^
      |                       ::
rail.cpp:76:19: error: 'inf' has not been declared
   76 |   for(const &auto inf : rig){
      |                   ^~~
rail.cpp:76:28: error: qualified-id in declaration before ')' token
   76 |   for(const &auto inf : rig){
      |                            ^
rail.cpp:76:28: error: expected ';' before ')' token
   76 |   for(const &auto inf : rig){
      |                            ^
      |                            ;
rail.cpp:77:14: error: 'inf' was not declared in this scope; did you mean 'int'?
   77 |     int n1 = inf.x;
      |              ^~~
      |              int
rail.cpp:88:16: error: 'getDistance' was not declared in this scope
   88 |       int n3 = getDistance(cur, n1);
      |                ^~~~~~~~~~~
rail.cpp:110:14: error: expected unqualified-id before 'auto'
  110 |   for(const &auto inf : lef){
      |              ^~~~
rail.cpp:110:14: error: expected ';' before 'auto'
  110 |   for(const &auto inf : lef){
      |              ^~~~
      |              ;
rail.cpp:110:23: error: found ':' in nested-name-specifier, expected '::'
  110 |   for(const &auto inf : lef){
      |                       ^
      |                       ::
rail.cpp:110:19: error: 'inf' has not been declared
  110 |   for(const &auto inf : lef){
      |                   ^~~
rail.cpp:110:28: error: qualified-id in declaration before ')' token
  110 |   for(const &auto inf : lef){
      |                            ^
rail.cpp:110:28: error: expected ';' before ')' token
  110 |   for(const &auto inf : lef){
      |                            ^
      |                            ;
rail.cpp:111:14: error: 'inf' was not declared in this scope; did you mean 'int'?
  111 |     int n1 = inf.x;
      |              ^~~
      |              int
rail.cpp:122:16: error: 'getDistance' was not declared in this scope
  122 |       int n3 = getDistance(cur, n1);
      |                ^~~~~~~~~~~