Submission #869437

#TimeUsernameProblemLanguageResultExecution timeMemory
869437lolismekStranded Far From Home (BOI22_island)C++14
Compilation error
0 ms0 KiB
#include <algorithm> #include <iostream> #include <fstream> #include <vector> #include <queue> #define pii pair <int, int> using namespace std; #ifdef LOCAL ifstream fin("input.in"); ofstream fout("output.out"); #elseif #define fin cin #define fout cout #endif const int NMAX = 2e5; int v[NMAX + 1]; vector <int> adj[NMAX + 1]; int par[NMAX + 1]; int sum[NMAX + 1]; int Find(int x){ if(x == par[x]){ return x; } return par[x] = Find(par[x]); } void Join(int x, int y){ x = par[x]; y = par[y]; par[x] = y; sum[y] += sum[x]; } bool ins[NMAX + 1]; void Insert(int x){ ins[x] = true; for(int vec : adj[x]){ if(ins[vec]){ Join(vec, x); } } } bool ans[NMAX + 1]; int main(){ int n, m; fin >> n >> m; vector <pii> aux; priority_queue <pii, vector <pii>, greater <pii>> pq; for(int i = 1; i <= n; i++){ fin >> v[i]; par[i] = i; sum[i] = v[i]; aux.push_back({v[i], i}); pq.push({v[i], i}); ans[i] = 1; } for(int i = 1; i <= m; i++){ int a, b; fin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } sort(aux.begin(), aux.end()); for(int i = 0; i < (int)aux.size(); i++){ cout << i << endl; int val = aux[i].first; Insert(aux[i].second); //cout << "-- " << aux[i].second << endl; while(i + 1 < (int)aux.size() && aux[i + 1].first == aux[i].first){ Insert(aux[++i].second); //cout << "-- " << aux[i].second << endl; } while(!pq.empty() && pq.top().first <= val){ int node = pq.top().second; int x = pq.top().first; pq.pop(); int s = sum[Find(node)]; if(s == x){ // cout << ">> " << node << ' ' << val << ' ' << x << ' ' << s << endl; ans[node] = 0; }else{ pq.push({s, node}); } } } for(int i = 1; i <= n; i++){ fout << ans[i]; } fout << '\n'; return 0; }

Compilation message (stderr)

island.cpp: In function 'int main()':
island.cpp:58:5: error: 'fin' was not declared in this scope
   58 |     fin >> n >> m;
      |     ^~~
island.cpp:108:9: error: 'fout' was not declared in this scope
  108 |         fout << ans[i];
      |         ^~~~
island.cpp:110:5: error: 'fout' was not declared in this scope
  110 |     fout << '\n';
      |     ^~~~