Submission #92561

#TimeUsernameProblemLanguageResultExecution timeMemory
92561ShtefNLO (COCI18_nlo)C++14
110 / 110
616 ms504 KiB
#include <iostream> #include <map> #include <vector> #include <cmath> #include <set> #include <utility> #include <algorithm> using namespace std; typedef long long ll; typedef long double ld; typedef pair <ll, ll> pll; #define x first #define y second #define mp make_pair struct query{ ll x, y, r; }; ll n, m, k; query a[105]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; cin >> k; for(int i = 0 ; i < k ; ++i){ cin >> a[i].x >> a[i].y >> a[i].r; } ll sol = 0; for(int i = 1 ; i <= m ; ++i){ ll last = 1; vector <pll> v; for(int j = 0 ; j < k ; ++j){ ll x = a[j].x, y = a[j].y, r = a[j].r, val = j + 1; if(i >= max(1LL, y - r) && i <= min(m, y + r)){ ll koef = (r - i + y) * (r + i - y); ld t = sqrt(koef); koef = (ll)t; v.push_back(mp(max(1LL, x - koef), val)); v.push_back(mp(min(n + 1, x + koef + 1), -val)); } } set <ll, greater <ll> > s; sort(v.begin(), v.end()); for(int j = 0 ; j < v.size() ; ){ ll t = v[j].x; sol += (t - last) * (k - (!s.empty() ? *s.begin() : 0LL)); while(j < v.size() && v[j].x == t){ ll o = v[j].y; if(o < 0){ s.erase(s.find(-o)); } else{ s.insert(o); } j++; } last = t; } sol += (n + 1 - last) * k; } cout << sol << endl; return 0; }

Compilation message (stderr)

nlo.cpp: In function 'int main()':
nlo.cpp:51:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0 ; j < v.size() ; ){
                  ~~^~~~~~~~~~
nlo.cpp:54:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j < v.size() && v[j].x == t){
         ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...