Submission #983796

#TimeUsernameProblemLanguageResultExecution timeMemory
983796Halym2007Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "cyberland.h" using namespace std; #define ff first #define ss second #define pb push_back #define sz size() #define ll long long #define pii pair <int, ll> #define piii pair <ll, int> const int N = 1e5 + 5; vector <pii> v[N]; priority_queue <piii, vector <piii>, greater <piii>> q; ll dis[N]; bool vis[N]; void dfs (int x) { vis[x] = 1; for (pii i : v[x]) { if (vis[i.ff]) continue; dfs (i.ff); } } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { for (int i = 0; i < M; ++i) { // cout << i << " --> " << x[i] << " " << y[i]; v[x[i]].pb ({y[i], (ll)c[i]}); v[y[i]].pb ({x[i], (ll)c[i]}); } for (int i = 0; i < N; ++i) { dis[i] = 1e18; } vis[H] = 1; dfs (0); vis[H] = 0; q.push ({0, H}); dis[H] = 0; while (!q.empty()) { int x = q.top().ss; q.pop(); for (pii i : v[x]) { if (dis[i.ff] > dis[x] + i.ss) { dis[i.ff] = dis[x] + i.ss; q.push({dis[i.ff], i.ff}); } } } // for (int i = 0; i < N; ++i) { // cout << i << " -- > " << dis[i] << " " << vis[i] << "\n"; // } // exit(0); arr[0] = 0; double jogap = -1; for (int i = 0; i < N; ++i) { if (!arr[i] and vis[i]) {  //assert (dis[i] <= (ll)1e9); if (jogap == -1) { jogap = (double)dis[i]; } else jogap = min (jogap, (double)dis[i]); } } for (int i = 0; i < N; ++i) { v[i].clear(); vis[i] = 0; } return jogap; } //int main() { // freopen ("input.txt", "r", stdin); // int T; // assert(1 == scanf("%d", &T)); // while (T--) { // int N,M,K,H; // assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H)); // std::vector<int> x(M); // std::vector<int> y(M); // std::vector<int> c(M); // std::vector<int> arr(N); // for (int i=0;i<N;i++) // assert(1 == scanf("%d", &arr[i])); // for (int i=0;i<M;i++) // assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i])); // printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr)); // } //}

Compilation message (stderr)

cyberland.cpp:60:3: error: extended character   is not valid in an identifier
   60 |    //assert (dis[i] <= (ll)1e9);
      |   ^
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:60:3: error: '\U000000a0' was not declared in this scope
   60 |    //assert (dis[i] <= (ll)1e9);
      |   ^
cyberland.cpp:64:4: error: expected '}' before 'else'
   64 |    else jogap = min (jogap, (double)dis[i]);
      |    ^~~~
cyberland.cpp:59:27: note: to match this '{'
   59 |   if (!arr[i] and vis[i]) {
      |                           ^
cyberland.cpp:66:2: warning: no return statement in function returning non-void [-Wreturn-type]
   66 |  }
      |  ^
cyberland.cpp: At global scope:
cyberland.cpp:68:2: error: expected unqualified-id before 'for'
   68 |  for (int i = 0; i < N; ++i) {
      |  ^~~
cyberland.cpp:68:18: error: 'i' does not name a type
   68 |  for (int i = 0; i < N; ++i) {
      |                  ^
cyberland.cpp:68:25: error: expected unqualified-id before '++' token
   68 |  for (int i = 0; i < N; ++i) {
      |                         ^~
cyberland.cpp:72:2: error: expected unqualified-id before 'return'
   72 |  return jogap;
      |  ^~~~~~
cyberland.cpp:73:1: error: expected declaration before '}' token
   73 | }
      | ^