답안 #775543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775543 2023-07-06T13:46:09 Z Trumling 벽 (IOI14_wall) C++14
0 / 100
0 ms 212 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({height[i],right[i]});
      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({-height[i],right[i]});
      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)
      |           ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -