제출 #599896

#제출 시각아이디문제언어결과실행 시간메모리
5998968e7Rail (IOI14_rail)C++17
컴파일 에러
0 ms0 KiB
//Challenge: Accepted
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ...b ){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 5005
#define pii pair<int, int>
#define ff first
#define ss second
const int inf = 1e9;

void findLocation(int N, int first, int location[], int stype[]) {
	vector<int> dl(N, 0), dr(N, 0);
	dl[0] = inf;
	for (int i = 1;i < N;i++) {
		dl[i] = getDistance(0, i);
	}
	location[0] = first;
	stype[0] = 1;
	if (N == 1) return;

	int rid = min_element(dl.begin(), dl.end()) - dl.begin();
	dr[rid] = inf;
	int llen = dl[rid];
	location[rid] = first + dl[rid];
	stype[rid] = 2;

	vector<pii> vl, vr;
					stype[i] = 1;
				} else {
					vl.push_back({dr[i], i});
				}
			}
		}	
	}		
	int lid = min_element(dr.begin(), dr.end()) - dr.begin();	
	for (int i = 0;i < N;i++) {
		if (i == rid) dl[i] = dr[lid];
		else if (i && dl[i] - dr[i] != llen) {
			debug("rig", i);
			dl[i] = dr[i] - dr[lid];
			vr.push_back({dl[i], i});
		}
	}
	debug("lid", lid, "rid", rid);
	sort(vl.begin(), vl.end()), sort(vr.begin(), vr.end());
	int lef = 0;
	for (auto [dis, id]:vl) {
		int p = getDistance(lef, id);
		if (dis - p == dr[lef]) {
			location[id] = location[lef] + p;
			stype[id] = 2;
		} else {
			location[id] = location[rid] - dis;
			stype[id] = 1;
			lef = id;
		}
	}
	int rig = rid;
	for (auto [dis, id]:vr) {
		int p = getDistance(rig, id);
		if (dis - p == dl[rig]) {
			location[id] = location[rig] - p;
			stype[id] = 1;
		} else {
			location[id] = location[lid] + dis;
			stype[id] = 2;
			rig = id;
		}
	}
	pary(stype,stype + N);
	pary(location, location + N);
}

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:40:12: error: 'i' was not declared in this scope
   40 |      stype[i] = 1;
      |            ^
rail.cpp:35:6: warning: unused variable 'llen' [-Wunused-variable]
   35 |  int llen = dl[rid];
      |      ^~~~
rail.cpp: At global scope:
rail.cpp:41:7: error: expected unqualified-id before 'else'
   41 |     } else {
      |       ^~~~
rail.cpp:44:4: error: expected declaration before '}' token
   44 |    }
      |    ^
rail.cpp:45:3: error: expected declaration before '}' token
   45 |   }
      |   ^
rail.cpp:46:2: error: expected declaration before '}' token
   46 |  }
      |  ^
rail.cpp:47:24: error: 'dr' was not declared in this scope
   47 |  int lid = min_element(dr.begin(), dr.end()) - dr.begin();
      |                        ^~
rail.cpp:47:36: error: 'dr' was not declared in this scope
   47 |  int lid = min_element(dr.begin(), dr.end()) - dr.begin();
      |                                    ^~
rail.cpp:47:48: error: 'dr' was not declared in this scope
   47 |  int lid = min_element(dr.begin(), dr.end()) - dr.begin();
      |                                                ^~
rail.cpp:48:2: error: expected unqualified-id before 'for'
   48 |  for (int i = 0;i < N;i++) {
      |  ^~~
rail.cpp:48:17: error: 'i' does not name a type
   48 |  for (int i = 0;i < N;i++) {
      |                 ^
rail.cpp:48:23: error: 'i' does not name a type
   48 |  for (int i = 0;i < N;i++) {
      |                       ^
rail.cpp:13:20: error: expected unqualified-id before numeric constant
   13 | #define debug(...) 0
      |                    ^
rail.cpp:56:2: note: in expansion of macro 'debug'
   56 |  debug("lid", lid, "rid", rid);
      |  ^~~~~
rail.cpp:57:6: error: expected constructor, destructor, or type conversion before '(' token
   57 |  sort(vl.begin(), vl.end()), sort(vr.begin(), vr.end());
      |      ^
rail.cpp:59:2: error: expected unqualified-id before 'for'
   59 |  for (auto [dis, id]:vl) {
      |  ^~~
rail.cpp:70:12: error: 'rid' was not declared in this scope; did you mean 'rig'?
   70 |  int rig = rid;
      |            ^~~
      |            rig
rail.cpp:71:2: error: expected unqualified-id before 'for'
   71 |  for (auto [dis, id]:vr) {
      |  ^~~
rail.cpp:14:19: error: expected unqualified-id before numeric constant
   14 | #define pary(...) 0
      |                   ^
rail.cpp:82:2: note: in expansion of macro 'pary'
   82 |  pary(stype,stype + N);
      |  ^~~~
rail.cpp:14:19: error: expected unqualified-id before numeric constant
   14 | #define pary(...) 0
      |                   ^
rail.cpp:83:2: note: in expansion of macro 'pary'
   83 |  pary(location, location + N);
      |  ^~~~
rail.cpp:84:1: error: expected declaration before '}' token
   84 | }
      | ^