Submission #347451

#TimeUsernameProblemLanguageResultExecution timeMemory
347451beksultan04Aliens (IOI16_aliens)C++14
0 / 100
2076 ms364 KiB
//#include "grader.cpp" #include "aliens.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scanl(a) scanf("%lld",&a); #define scanll(a,b) scanf("%lld %lld",&a, &b); #define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define scan1(a) scanf("%d",&a); #define scan2(a,b) scanf("%d %d",&a, &b); #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin()Ñ,s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-12 ll n,m,k,ans; bool vis[500001]; void changes(int &l,int &r){ while (vis[l] == 0 && l < m)l++; while (vis[r] == 0 && r >= 0)r--; } ll take_photos(int n, int m, int k,vector<int> r,vector<int> c) { int i,j; ::n = n; ::m = m; for (i=0;i<n;++i){ vis[r[i]]=1; } int x = 0; int y = m; priority_queue <pair<ll,pair<ll,ll > >>q; changes(x,y); q.push({y-x+1,{x,y}}); while (q.size() < k){ int l = q.top().sc.fr; int r = q.top().sc.sc; q.pop(); int p = (l+r>>1); int a = l; int b = p; changes(a,b); if (a <= b){ q.push({b-a+1,{a,b}}); } l = p+1; r = r; changes(l,r); if (l <= r){ q.push({r-l+1,{l,r}}); } } while (!q.empty()){ ans += q.top().fr*q.top().fr; int l = q.top().sc.fr; int r = q.top().sc.sc; q.pop(); } return ans; }

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:44:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     while (q.size() < k){
      |            ~~~~~~~~~^~~
aliens.cpp:48:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |         int p = (l+r>>1);
      |                  ~^~
aliens.cpp:65:13: warning: unused variable 'l' [-Wunused-variable]
   65 |         int l = q.top().sc.fr;
      |             ^
aliens.cpp:66:13: warning: unused variable 'r' [-Wunused-variable]
   66 |         int r = q.top().sc.sc;
      |             ^
aliens.cpp:33:11: warning: unused variable 'j' [-Wunused-variable]
   33 |     int i,j;
      |           ^
#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...