Submission #347451

# Submission time Handle Problem Language Result Execution time Memory
347451 2021-01-13T05:32:24 Z beksultan04 Aliens (IOI16_aliens) C++14
0 / 100
2000 ms 364 KB
//#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

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 time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Correct answer: answer = 1
2 Correct 1 ms 364 KB Correct answer: answer = 4
3 Execution timed out 2076 ms 364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -