제출 #1241266

#제출 시각아이디문제언어결과실행 시간메모리
1241266hynmjStations (IOI20_stations)C++20
컴파일 에러
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; map<int, vector<int>> graph; vector<int> labels; int times; void dfs(int node, int parent, int depth) { if ((depth )%2==1) { labels[node] = ++times; } for (int i:graph[node]) { if (i!=parent) { dfs(i,node,depth+1); } } if ((depth )%2==0) { labels[node] = ++times; } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { times = -1; labels.resize(n); for (int i=0;i<n-1; i++) { graph[u[i]].push_back(v[i]); graph[v[i]].push_back(u[i]); } dfs(1,-1,0); graph.clear(); return labels; } int find_next_station(int s, int t, std::vector<int> c) { int n = c.size(); if (n==1) return c[0]; if (s <= c[0]) { if (t<c[0] return c[n-1]; for (int i=n-1;i;i--) { if (c[i-1] < s and c[i] <= s) { return c[i]; } } return c[0]; } else { for (int i=1;i<n-1;i++) { if (c[i-1] <= s and c[i] < s) { return c[i]; } return c[n-1]; } } return -1; }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:17: error: expected ';' before 'return'
   48 |       if (t<c[0] return c[n-1];
      |                 ^~~~~~~
      |                 ;
stations.cpp:49:7: error: expected primary-expression before 'for'
   49 |       for (int i=n-1;i;i--)
      |       ^~~
stations.cpp:48:32: error: expected ')' before 'for'
   48 |       if (t<c[0] return c[n-1];
      |          ~                     ^
      |                                )
   49 |       for (int i=n-1;i;i--)
      |       ~~~                       
stations.cpp:49:22: error: 'i' was not declared in this scope
   49 |       for (int i=n-1;i;i--)
      |                      ^