제출 #397243

#제출 시각아이디문제언어결과실행 시간메모리
397243rocks03열대 식물원 (Tropical Garden) (IOI11_garden)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXK = 30; const int MAXN = 2e5+100; int N, M, P, nxt[2][MAXK][MAXN], wei[2][MAXK][MAXN]; vector<pii> g[MAXN]; void build(){ rep(i, 0, N){ sort(all(g[i]), greater<pii>()); while(SZ(g[i]) > 2) g[i].pop_back(); if(SZ(g[i]) < 2) g[i].pb(g[i][0]); nxt[0][0][i] = g[i][0].ss; wei[0][0][i] = g[i][0].ff; nxt[1][0][i] = g[i][1].ss; wei[1][0][i] = g[i][1].ff; } rep(k, 0, MAXK - 1){ rep(i, 0, N){ int u; u = nxt[0][k][i]; nxt[0][k + 1][i] = nxt[0][k][u]; wei[0][k + 1][i] = wei[0][k][u]; if(wei[0][k][i] == wei[0][0][u]){ nxt[0][k + 1][i] = nxt[1][k][u]; wei[0][k + 1][i] = wei[1][k][u]; } u = nxt[1][k][i]; nxt[1][k + 1][i] = nxt[0][k][u]; wei[1][k + 1][i] = wei[0][k][u]; if(wei[1][k][i] == wei[0][0][u]){ nxt[1][k + 1][i] = nxt[1][k][u]; wei[1][k + 1][i] = wei[1][k][u]; } } } } int jump(int v, int K){ int w = -1; per(k, MAXK - 1, 0){ if(K >> k & 1){ if(wei[0][0][v] != w){ w = wei[0][k][v]; v = nxt[0][k][v]; } else{ w = wei[1][k][v]; v = nxt[1][k][v]; } } } return v; } int query(int K){ int ans = 0; rep(i, 0, N){ if(jump(i, K) == P) ans++; } return ans; } void solve(){ cin >> N >> M >> P; per(m, M - 1, 0){ int u, v; cin >> u >> v; g[u].pb({m, v}); g[v].pb({m, u}); } build(); int Q; cin >> Q; rep(q, 0, Q){ int K; cin >> K; cout << query(K) << "\n"; } } int main(){ ios_base::sync_with_stdio(false), cin.tie(nullptr); solve(); return 0; }

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

/tmp/cc2syx1i.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccWqZbMm.o:garden.cpp:(.text.startup+0x0): first defined here
/tmp/cc2syx1i.o: In function `main':
grader.cpp:(.text.startup+0x3b): undefined reference to `count_routes(int, int, int, int (*) [2], int, int*)'
collect2: error: ld returned 1 exit status