Submission #42796

#TimeUsernameProblemLanguageResultExecution timeMemory
42796funcsrAliens (IOI16_aliens)C++14
Compilation error
0 ms0 KiB
#include "aliens.h" #include <iostream> #include <vector> #include <string> #include <cassert> using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i=0; i<(n); i++) #define all(x) x.begin(), x.end() #define pb push_back #define INF 1145141919 #define _1 first #define _2 second long long take_photos(int N, int M, int K, std::vector<int> R, std::vector<int> C) { vector<P> ps; rep(i, N) { int l = R[i], r = C[i]; if (l > r) swap(l, r); ps.pb(P(l, -r)); } sort(all(ps)); int r = -1; vector<P> nps; for (P p : ps) { if (-p._2 > r) { nps.pb(P(p._1, -p._2)); r = -p._2; } } swap(ps, nps); int last_r = -1; long long s = 0; assert(K==N); for (P p : ps) { int l = p._1, r = p._2; //cout<<"["<<l<<","<<r<<"]\n"; s += 1LL*(r-l+1)*(r-l+1); if (l <= last_r) s -= 1LL*(last_r-l+1)*(last_r-l+1); last_r = r; } return s; }

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:22:15: error: 'sort' was not declared in this scope
   sort(all(ps));
               ^