Submission #1108579

#TimeUsernameProblemLanguageResultExecution timeMemory
1108579chaoslongRobot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
// Calm down. // Think three times, code twice. #include "bits/stdc++.h" #define forr(_a,_b,_c) for(int _a = (_b); _a <= (_c); ++_a) #define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> (_c);) #define forf(_a,_b,_c) for(int _a = (_b); _a < (_c); ++_a) #define fore(x, v) for(auto &x : v) #define st first #define nd second #define ll long long #define ull unsigned long long #define pii pair <ll,int> #define pll pair <ll,ll> #define piii pair <ll,pii> #define vi vector <int> #define pb push_back #define mp make_pair #define all(x) begin(x),end(x) #define mask(i) (1LL << (i)) #define bit(x, i) (((x) >> (i)) & 1) #define bp __builtin_popcountll #define file "test" using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; // 998244353 const ll oo = 1e18; int n, m; map<int, vector<ii>> graph[N]; ll dp[N]; map<int, ll> dp2[N], sum[N]; int main() { cin >> n >> m; foru(i, 1, m) { int u, v, c, p; cin >> u >> v >> c >> p; graph[u][c].emplace_back(v, p); graph[v][c].emplace_back(u, p); sum[u][c] += p; sum[v][c] += p; } memset(dp, 0x3f, sizeof(dp)); priority_queue<pair<ll, ii>> pq; dp[1] = 0; pq.push({0, {1, 0}}); while (!pq.empty()) { auto top = pq.top(); pq.pop(); ll cost = top.fi; int u = top.se.fi, c = top.se.se; if (!c) { if (-cost != dp[u]) continue; fore(nc, graph[u]) fore(info, nc.se) { int v = info.fi, p = info.se; ll ncost; ncost = sum[u][nc.fi] - p - cost; if (ncost < dp[v]) { dp[v] = ncost; pq.push({-ncost, {v, 0}}); } ncost = p - cost; if (ncost < dp[v]) { dp[v] = ncost; pq.push({-ncost, {v, 0}}); } ncost = -cost; if ((dp2[v].find(nc.fi) == dp2[v].end()) || ncost < dp2[v][nc.fi]) { dp2[v][nc.fi] = ncost; pq.push({-ncost, {v, nc.fi}}); } } } else { if (-cost != dp2[u][c]) continue; ll ncost = sum[u][c] - cost; fore(info, graph[u][c]) { int v = info.fi, p = info.se; if (ncost - p < dp[v]) { dp[v] = ncost - p; pq.push({-ncost + p, {v, 0}}); } } } } cout << (dp[n] < oo ? dp[n] : -1); } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); #ifdef LOCAL freopen(file".inp","r",stdin); freopen(file".out","w",stdout); #endif // LOCAL int t = 1; // cin >> t; while(t--) to_nho_cau(); } /* 1.self check: 2.long long 3.size of array 4.code for testing 5.initializing 6.modulo number */

Compilation message (stderr)

Main.cpp:30:17: error: 'ii' was not declared in this scope; did you mean 'vi'?
   30 | map<int, vector<ii>> graph[N];
      |                 ^~
      |                 vi
Main.cpp:30:17: error: template argument 1 is invalid
Main.cpp:30:17: error: template argument 2 is invalid
Main.cpp:30:19: error: template argument 2 is invalid
   30 | map<int, vector<ii>> graph[N];
      |                   ^~
Main.cpp:30:19: error: template argument 4 is invalid
Main.cpp: In function 'int main()':
Main.cpp:37:8: error: 'i' was not declared in this scope
   37 |   foru(i, 1, m) {
      |        ^
Main.cpp:37:3: error: 'foru' was not declared in this scope; did you mean 'ford'?
   37 |   foru(i, 1, m) {
      |   ^~~~
      |   ford
Main.cpp:47:27: error: 'ii' was not declared in this scope; did you mean 'vi'?
   47 |   priority_queue<pair<ll, ii>> pq;
      |                           ^~
      |                           vi
Main.cpp:47:27: error: template argument 2 is invalid
Main.cpp:47:29: error: template argument 1 is invalid
   47 |   priority_queue<pair<ll, ii>> pq;
      |                             ^~
Main.cpp:47:29: error: template argument 2 is invalid
Main.cpp:47:29: error: template argument 3 is invalid
Main.cpp:49:6: error: request for member 'push' in 'pq', which is of non-class type 'int'
   49 |   pq.push({0, {1, 0}});
      |      ^~~~
Main.cpp:51:14: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   51 |   while (!pq.empty()) {
      |              ^~~~~
Main.cpp:52:19: error: request for member 'top' in 'pq', which is of non-class type 'int'
   52 |     auto top = pq.top(); pq.pop();
      |                   ^~~
Main.cpp:52:29: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   52 |     auto top = pq.top(); pq.pop();
      |                             ^~~
Main.cpp:57:10: error: 'c' was not declared in this scope
   57 |     if (!c) {
      |          ^
Main.cpp:59:23: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   59 |       fore(nc, graph[u]) fore(info, nc.se) {
      |                       ^
Main.cpp:7:34: note: in definition of macro 'fore'
    7 | #define fore(x, v) for(auto &x : v)
      |                                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from Main.cpp:3:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
Main.cpp:59:23: error: 'end' was not declared in this scope; did you mean 'std::end'?
   59 |       fore(nc, graph[u]) fore(info, nc.se) {
      |                       ^
Main.cpp:7:34: note: in definition of macro 'fore'
    7 | #define fore(x, v) for(auto &x : v)
      |                                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from Main.cpp:3:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
Main.cpp:63:33: error: 'p' was not declared in this scope
   63 |         ncost = sum[u][nc.fi] - p - cost;
      |                                 ^
Main.cpp:66:14: error: request for member 'push' in 'pq', which is of non-class type 'int'
   66 |           pq.push({-ncost, {v, 0}});
      |              ^~~~
Main.cpp:72:14: error: request for member 'push' in 'pq', which is of non-class type 'int'
   72 |           pq.push({-ncost, {v, 0}});
      |              ^~~~
Main.cpp:78:14: error: request for member 'push' in 'pq', which is of non-class type 'int'
   78 |           pq.push({-ncost, {v, nc.fi}});
      |              ^~~~
Main.cpp:87:21: error: 'p' was not declared in this scope
   87 |         if (ncost - p < dp[v]) {
      |                     ^
Main.cpp:89:14: error: request for member 'push' in 'pq', which is of non-class type 'int'
   89 |           pq.push({-ncost + p, {v, 0}});
      |              ^~~~
Main.cpp: At global scope:
Main.cpp:98:8: error: redefinition of 'int main()'
   98 | signed main(){
      |        ^~~~
Main.cpp:34:5: note: 'int main()' previously defined here
   34 | int main() {
      |     ^~~~
Main.cpp: In function 'int main()':
Main.cpp:106:16: error: 'to_nho_cau' was not declared in this scope
  106 |     while(t--) to_nho_cau();
      |                ^~~~~~~~~~