Submission #971754

#TimeUsernameProblemLanguageResultExecution timeMemory
971754Halym2007Palembang Bridges (APIO15_bridge)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #define ll long long int #define pb push_back #define ff first #define ss second #define sz size() const int N = 2e5 + 1; using namespace std; int k, n, vis[N]; ll mn = 1e15, sum; pair <char,int> a[N], b[N]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> k >> n; for(int i = 1; i <= n; i++){ cin >> a[i].ff >> a[i].ss >> b[i].ff >> b[i].ss; if(a[i].ff != b[i].ff){ v.pb(b[i].ss); v.pb(a[i].ss); } else sum += abs(a[i].ss-b[i].ss); } sort(v.begin(), v.end()); for(int i = 0; i < v.sz; i++){ p[i+1] = v[i] + p[i]; } for(int i = 0; i < v.sz; i++){ mn = min(mn,(i+1)*v[i] - p[i+1] + p[v.sz] - p[i+1] - (v.sz-i-1)*v[i]); } cout << mn + sum; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:24:5: error: 'v' was not declared in this scope
   24 |     v.pb(b[i].ss);
      |     ^
bridge.cpp:29:10: error: 'v' was not declared in this scope
   29 |     sort(v.begin(), v.end());
      |          ^
bridge.cpp:31:5: error: 'p' was not declared in this scope
   31 |     p[i+1] = v[i] + p[i];
      |     ^
bridge.cpp:34:30: error: 'p' was not declared in this scope
   34 |     mn = min(mn,(i+1)*v[i] - p[i+1] + p[v.sz] - p[i+1] - (v.sz-i-1)*v[i]);
      |                              ^