Submission #775546

# Submission time Handle Problem Language Result Execution time Memory
775546 2023-07-06T13:47:24 Z Trumling Wall (IOI14_wall) C++14
0 / 100
1 ms 244 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int *finalHeight){
vector<pair<int,pair<int,int>>>v;
  for(int i=0;i<k;i++)
  {
    if(op[i]==2)
    break;
    v.pb({left[i],{height[i],right[i]}});
  
  }
  sort(all(v));
  ll idx=0;
  priority_queue<pair<int,int>>pq;
  for(int i=0;i<n;i++)
  {
    while(idx<v.size() && v[i].F==i)
    {
      pq.push({v[idx].S.F,v[idx].S.S});
      idx++;
    }

    while(!pq.empty() && pq.top().S<i)
      pq.pop();

    finalHeight[i]=pq.top().F;
  }
  while(!pq.empty())
  pq.pop();

  v.clear();

  for(int i=0;i<k;i++)
  {
    if(op[i]==1)
    continue;
    v.pb({left[i],{height[i],right[i]}});
  }

  sort(all(v));
  for(int i=0;i<n;i++)
  {
    while(idx<v.size() && v[i].F==i)
    {
      pq.push({-v[idx].S.F,v[idx].S.S});
      idx++;
    }

    while(!pq.empty() && pq.top().S<i)
      pq.pop();
    
    finalHeight[i]=min(-pq.top().F,finalHeight[i]);
  }

  return; 
}

Compilation message

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:28:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     while(idx<v.size() && v[i].F==i)
      |           ~~~^~~~~~~~~
wall.cpp:54:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     while(idx<v.size() && v[i].F==i)
      |           ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 244 KB Output isn't correct
2 Halted 0 ms 0 KB -