제출 #976224

#제출 시각아이디문제언어결과실행 시간메모리
976224Tsagana사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> // START struct country { double cost[31]; }; country cnt[100001]; vector<pi> adj[100001]; vi ar; int h, D; int vs[100001]; vi takes(int s) { vi v; pq<int> q; q.push(s); while (!q.empty()) { s = q.top(); q.pop(); for (auto i: adj[s]) { if (vs[i.S]) continue ; vs[i.S] = 1; if (!ar[i.S]) v.pb(i.S); q.push(i.S); } } return v; } void dfs(int s, int k, double cos) { if (k > D) return ; if (cnt[s].cost[k] <= cos) return ; cnt[s].cost[k] = cos; // cout << s << ' ' << k << ' '; // printf("%.12lf\n", cos); if (s == h) return ; for (auto i: adj[s]) { double c = i.F; int x = i.S; dfs(x, k, c + cos); if (ar[s] == 2 && k <= D) dfs(x, k + 1, c + (cos / 2.0)); } } double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) { ar = arr; h = H; D = K; for (int i = 0; i < M; i++) { adj[x[i]].pb({c[i], y[i]}); adj[y[i]].pb({c[i], x[i]}); } for (int i = 0; i < N; i++) { for (int j = 0; j <= K; j++) { cnt[i].cost[j] = 1e9; } } vi v = takes(0); for (auto i: v) { adj[0].pb({0, i}); } dfs(0, 0, 0.0); double ans = cnt[H].cost[0]; for (int i = 1; i <= K; i++) { if (ans > cnt[H].cost[i]) ans = cnt[H].cost[i]; } return ans; } //END

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

cyberland.cpp:13:1: error: 'vector' does not name a type
   13 | vector<pi> adj[100001];
      | ^~~~~~
cyberland.cpp:14:1: error: 'vi' does not name a type
   14 | vi ar;
      | ^~
cyberland.cpp:18:1: error: 'vi' does not name a type; did you mean 'vs'?
   18 | vi takes(int s) {
      | ^~
      | vs
cyberland.cpp: In function 'void dfs(int, int, double)':
cyberland.cpp:42:16: error: 'adj' was not declared in this scope
   42 |   for (auto i: adj[s]) {
      |                ^~~
cyberland.cpp:47:9: error: 'ar' was not declared in this scope
   47 |     if (ar[s] == 2 && k <= D) dfs(x, k + 1, c + (cos / 2.0));
      |         ^~
cyberland.cpp: At global scope:
cyberland.cpp:50:42: error: 'vi' has not been declared
   50 | double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
      |                                          ^~
cyberland.cpp:50:48: error: 'vi' has not been declared
   50 | double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
      |                                                ^~
cyberland.cpp:50:54: error: 'vi' has not been declared
   50 | double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
      |                                                      ^~
cyberland.cpp:50:60: error: 'vi' has not been declared
   50 | double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
      |                                                            ^~
cyberland.cpp: In function 'double solve(int, int, int, int, int, int, int, int)':
cyberland.cpp:51:3: error: 'ar' was not declared in this scope; did you mean 'arr'?
   51 |   ar = arr;
      |   ^~
      |   arr
cyberland.cpp:54:5: error: 'adj' was not declared in this scope
   54 |     adj[x[i]].pb({c[i], y[i]});
      |     ^~~
cyberland.cpp:54:10: error: invalid types 'int[int]' for array subscript
   54 |     adj[x[i]].pb({c[i], y[i]});
      |          ^
cyberland.cpp:54:20: error: invalid types 'int[int]' for array subscript
   54 |     adj[x[i]].pb({c[i], y[i]});
      |                    ^
cyberland.cpp:54:26: error: invalid types 'int[int]' for array subscript
   54 |     adj[x[i]].pb({c[i], y[i]});
      |                          ^
cyberland.cpp:55:10: error: invalid types 'int[int]' for array subscript
   55 |     adj[y[i]].pb({c[i], x[i]});
      |          ^
cyberland.cpp:55:20: error: invalid types 'int[int]' for array subscript
   55 |     adj[y[i]].pb({c[i], x[i]});
      |                    ^
cyberland.cpp:55:26: error: invalid types 'int[int]' for array subscript
   55 |     adj[y[i]].pb({c[i], x[i]});
      |                          ^
cyberland.cpp:62:3: error: 'vi' was not declared in this scope; did you mean 'vs'?
   62 |   vi v = takes(0);
      |   ^~
      |   vs
cyberland.cpp:63:16: error: 'v' was not declared in this scope
   63 |   for (auto i: v) {
      |                ^
cyberland.cpp:64:5: error: 'adj' was not declared in this scope
   64 |     adj[0].pb({0, i});
      |     ^~~