답안 #883473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883473 2023-12-05T10:32:29 Z ono_de206 철로 (IOI14_rail) C++17
컴파일 오류
0 ms 0 KB
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

//#define int long long

typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void findLocation(int n, int first, int pos[], int tp[]) {
	pos[0] = first;
	tp[0] = 1;

	vector<vector<int>> dis(n, vector<int>(n, -1));

	auto get = [&](int x, int y) -> int {
		if(x > y) swap(x, y);
		if(dis[x][y] != -1) return dis[x][y];
		return dis[x][y] = getDistance(x, y);
	};

	for(int i = 1; i < n; i++)  {
		vector<int> lol;
		for(int j = 1; j < n; j++) {
			if(i == j) continue;
			if(get(0, i) == get(0, j) + get(j, i)) lol.pb(j);
		}
		int x = first, ls = 0, k = 0;
		lol.pb(i);
		for(y : lol) {
			if(k) {
				x -= get(ls, y);
			} else {
				x += get(ls, y);
			}
			ls = y;
			k ^= 1;
		}
		pos[i] = x;
		tp[i] = k + 1;
	}
}

Compilation message

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:41:9: error: found ':' in nested-name-specifier, expected '::'
   41 |   for(y : lol) {
      |         ^
      |         ::
rail.cpp:41:7: error: 'y' has not been declared
   41 |   for(y : lol) {
      |       ^
rail.cpp:50:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   50 |   pos[i] = x;
      |   ~~~~~~~^~~
rail.cpp:51:16: error: expected ')' before ';' token
   51 |   tp[i] = k + 1;
      |                ^
      |                )
rail.cpp:41:6: note: to match this '('
   41 |   for(y : lol) {
      |      ^
rail.cpp:39:18: warning: unused variable 'ls' [-Wunused-variable]
   39 |   int x = first, ls = 0, k = 0;
      |                  ^~