Submission #300036

#TimeUsernameProblemLanguageResultExecution timeMemory
300036MarcoMeijerAliens (IOI16_aliens)C++14
0 / 100
1 ms384 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define RE(a,b) REP(a,0,b) #define FOR(a,b) for(auto& a:b) #define pb push_back #define fi first #define se second #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int INF=1e9; const int MX=1e5; vi r, c, le, ri; int n, m, k; int SA[MX]; ll take_photos(int _n, int _m, int _k, vi _r, vi _c) { n=_n; m=_m; k=_k; r=_r; c=_c; RE(i,n) if(c[i] < r[i]) swap(c[i], r[i]); RE(i,n) SA[i] = i; sort(SA,SA+n,[](int i, int j) { if(r[i] == r[j]) return c[i] > c[j]; return r[i] < r[j]; }); int mxr = -1; RE(i,n) { if(c[SA[i]] <= mxr) continue; le.pb(r[SA[i]]); ri.pb(c[SA[i]]); mxr = c[SA[i]]; } n = le.size(); ll ans = 0; RE(i,n) { ll w = ri[i]-le[i]+1; ans += w*w; if(i != n-1) { ll sw = ri[i]-le[i+1]; if(sw > 0) ans -= sw*sw; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...