제출 #719267

#제출 시각아이디문제언어결과실행 시간메모리
719267Joshi503경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
// #include <bits/stdc++.h> #include "race.h" using namespace std; using ll = long long; #define int ll using db = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; #define f first #define s second #define tcT template<class T #define tcTU tcT, class U tcT> using V = vector<T>; tcT, size_t SZ > using AR = array<T, SZ>; using vi = V<int>; using vb = V<bool>; using vl = V<ll>; using vd = V<db>; using vs = V<str>; using vpi = V<pi>; using vpl = V<pl>; #define sz(x) ll((x).size()) #define bg(x) begin(x) #define all(x) bg(x), end(x) #define rall(x) x.rbegin(), x.rend() #define sor(x) sort(all(x)) #define pb push_back #define yes cout << "Y" << "e" << "s\n"; #define no cout << "N" << "o\n"; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = ((b)-1); i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define rep(a) F0R(_,a) #define each(a,x) for (auto& a: x) const int MOD = 998244353; const int MOD98 = 998244353; const int MX = 1e9; const int INF = 1e18; const db PI = acos((db)-1); // const int dx[] = { 1,0,-1,0 }; // const int dy[] = { 0,1,0,-1 }; mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if ((ll)(name.size())) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } void _print(char i) { cerr << i; } void _print(string i) { cerr << i; } void _print(float i) { cerr << i; } void _print(int i) { cerr << i; } void _print(double i) { cerr << i; } void _print() { cerr << "\n"; }; template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; } template<typename x> void _print(x& t) { cerr << "{"; for (int i = 0;i < (int)t.size();i++) { _print(t[i]); if (i < (int)t.size() - 1) cerr << ", "; } cerr << "}"; } template<typename x, typename... y> void _print(x a, y... b) { _print(a);if (sizeof...(b)) cerr << ", ";_print(b...); } #define dbg(x...) cerr<<"["<<#x<<"] = [";_print(x);cerr<<"]\n"; int test; /* */ int n, k; vi d; vector<vpi> adj; int mini; void dfs(int u, int p, int len = 1){ each(v, adj[u]){ if(v.f == p) continue; d[v.f] = d[u] + v.s; if(d[v.f] == k){ mini = min(mini, len); } dfs(v.f, u, len + 1); } } int best_path(int N, int K, int H[][2], int L[]){ adj = vector<vpi>(N + 1); n = N, k = K; F0R(i, N - 1){ int u = H[i][0], v = H[i][1]; adj[u].pb({v, L[i]}); adj[v].pb({u, L[i]}); } int ans = 1e18; F0R(i, N){ mini = 1e18; d = vi(N + 1, 0LL); dfs(i, -1); ans = min(mini, ans); } return ans; } // signed main() { // setIO(""); // int T = 1; // // cin >> T; // for (test = 1; test <= T; test++) { // // cout << "Case #" << test << ": " << a.f << " " << a.s << "\n"; // // solve(); // int N, K; cin >> N >> K; // int H[N][2], L[N]; // F0R(i, N - 1) cin >> H[i][0] >> H[i][1]; // F0R(i, N) cin >> L[i]; // cout << best_path(N, K, H, L); // } // }

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

race.cpp:8:13: error: 'string' does not name a type
    8 | using str = string;
      |             ^~~~~~
race.cpp:9:12: error: 'pair' does not name a type
    9 | using pi = pair<int, int>;
      |            ^~~~
race.cpp:10:12: error: 'pair' does not name a type
   10 | using pl = pair<ll, ll>;
      |            ^~~~
race.cpp:11:12: error: 'pair' does not name a type
   11 | using pd = pair<db, db>;
      |            ^~~~
race.cpp:17:16: error: 'vector' does not name a type
   17 | tcT> using V = vector<T>;
      |                ^~~~~~
race.cpp:18:6: error: 'size_t' has not been declared
   18 | tcT, size_t SZ > using AR = array<T, SZ>;
      |      ^~~~~~
race.cpp:18:29: error: 'array' does not name a type
   18 | tcT, size_t SZ > using AR = array<T, SZ>;
      |                             ^~~~~
race.cpp:19:12: error: 'V' does not name a type
   19 | using vi = V<int>;
      |            ^
race.cpp:20:12: error: 'V' does not name a type
   20 | using vb = V<bool>;
      |            ^
race.cpp:21:12: error: 'V' does not name a type
   21 | using vl = V<ll>;
      |            ^
race.cpp:22:12: error: 'V' does not name a type
   22 | using vd = V<db>;
      |            ^
race.cpp:23:12: error: 'V' does not name a type
   23 | using vs = V<str>;
      |            ^
race.cpp:24:13: error: 'V' does not name a type
   24 | using vpi = V<pi>;
      |             ^
race.cpp:25:13: error: 'V' does not name a type
   25 | using vpl = V<pl>;
      |             ^
race.cpp:47:15: error: 'acos' was not declared in this scope
   47 | const db PI = acos((db)-1);
      |               ^~~~
race.cpp:50:1: error: 'mt19937' does not name a type
   50 | mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
      | ^~~~~~~
race.cpp:51:31: error: 'priority_queue' does not name a type
   51 | template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
      |                               ^~~~~~~~~~~~~~
race.cpp:52:6: error: variable or field 'setIO' declared void
   52 | void setIO(string name = "") {
      |      ^~~~~
race.cpp:52:12: error: 'string' was not declared in this scope
   52 | void setIO(string name = "") {
      |            ^~~~~~
race.cpp:3:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
    2 | #include "race.h"
  +++ |+#include <string>
    3 | using namespace std;
race.cpp: In function 'void _print(char)':
race.cpp:65:23: error: 'cerr' was not declared in this scope
   65 | void _print(char i) { cerr << i; }
      |                       ^~~~
race.cpp:3:1: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    2 | #include "race.h"
  +++ |+#include <iostream>
    3 | using namespace std;
race.cpp: At global scope:
race.cpp:66:6: error: variable or field '_print' declared void
   66 | void _print(string i) { cerr << i; }
      |      ^~~~~~
race.cpp:66:13: error: 'string' was not declared in this scope
   66 | void _print(string i) { cerr << i; }
      |             ^~~~~~
race.cpp:66:13: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
race.cpp: In function 'void _print(float)':
race.cpp:67:24: error: 'cerr' was not declared in this scope
   67 | void _print(float i) { cerr << i; }
      |                        ^~~~
race.cpp:67:24: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
race.cpp: In function 'void _print(ll)':
race.cpp:68:22: error: 'cerr' was not declared in this scope
   68 | void _print(int i) { cerr << i; }
      |                      ^~~~
race.cpp:68:22: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
race.cpp: In function 'void _print(double)':
race.cpp:69:25: error: 'cerr' was not declared in this scope
   69 | void _print(double i) { cerr << i; }
      |                         ^~~~
race.cpp:69:25: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
race.cpp: In function 'void _print()':
race.cpp:70:17: error: 'cerr' was not declared in this scope
   70 | void _print() { cerr << "\n"; };
      |                 ^~~~
race.cpp:70:17: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
race.cpp: At global scope:
race.cpp:71:39: error: variable or field '_print' declared void
   71 | template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; }
      |                                       ^~~~~~
race.cpp:71:46: error: 'pair' was not declared in this scope
   71 | template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; }
      |                                              ^~~~
race.cpp:3:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
    2 | #include "race.h"
  +++ |+#include <utility>
    3 | using namespace std;
race.cpp:71:52: error: expected primary-expression before ',' token
   71 | template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; }
      |                                                    ^
race.cpp:71:55: error: expected primary-expression before '>' token
   71 | template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; }
      |                                                       ^
race.cpp:71:58: error: 't' was not declared in this scope
   71 | template<typename x, typename y> void _print(pair<x, y>& t) { cerr << "{";_print(t.first);cerr << ", ";_print(t.second);cerr << "},"; }
      |                                                          ^
race.cpp: In function 'void _print(x&)':
race.cpp:72:42: error: 'cerr' was not declared in this scope
   72 | template<typename x> void _print(x& t) { cerr << "{"; for (int i = 0;i < (int)t.size();i++) { _print(t[i]); if (i < (int)t.size() - 1) cerr << ", "; } cerr << "}"; }
      |                                          ^~~~
race.cpp:72:42: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
race.cpp: In function 'void _print(x, y ...)':
race.cpp:73:92: error: 'cerr' was not declared in this scope
   73 | template<typename x, typename... y> void _print(x a, y... b) { _print(a);if (sizeof...(b)) cerr << ", ";_print(b...); }
      |                                                                                            ^~~~
race.cpp:73:92: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
race.cpp: At global scope:
race.cpp:83:1: error: 'vi' does not name a type
   83 | vi d;
      | ^~
race.cpp:84:1: error: 'vector' does not name a type
   84 | vector<vpi> adj;
      | ^~~~~~
race.cpp: In function 'void dfs(ll, ll, ll)':
race.cpp:87:13: error: 'adj' was not declared in this scope
   87 |     each(v, adj[u]){
      |             ^~~
race.cpp:41:33: note: in definition of macro 'each'
   41 | #define each(a,x) for (auto& a: x)
      |                                 ^
race.cpp:89:9: error: 'd' was not declared in this scope
   89 |         d[v.f] = d[u] + v.s;
      |         ^
race.cpp:91:20: error: 'min' was not declared in this scope; did you mean 'mini'?
   91 |             mini = min(mini, len);
      |                    ^~~
      |                    mini
race.cpp: In function 'll best_path(ll, ll, ll (*)[2], ll*)':
race.cpp:98:5: error: 'adj' was not declared in this scope
   98 |     adj = vector<vpi>(N + 1);
      |     ^~~
race.cpp:98:11: error: 'vector' was not declared in this scope
   98 |     adj = vector<vpi>(N + 1);
      |           ^~~~~~
race.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include "race.h"
  +++ |+#include <vector>
    3 | using namespace std;
race.cpp:98:18: error: 'vpi' was not declared in this scope
   98 |     adj = vector<vpi>(N + 1);
      |                  ^~~
race.cpp:108:9: error: 'd' was not declared in this scope
  108 |         d = vi(N + 1, 0LL);
      |         ^
race.cpp:108:13: error: 'vi' was not declared in this scope; did you mean 'i'?
  108 |         d = vi(N + 1, 0LL);
      |             ^~
      |             i
race.cpp:110:15: error: 'min' was not declared in this scope; did you mean 'mini'?
  110 |         ans = min(mini, ans);
      |               ^~~
      |               mini