답안 #775559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775559 2023-07-06T13:57:50 Z Trumling 벽 (IOI14_wall) C++14
24 / 100
208 ms 31640 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[idx].F==i)
    {
      pq.push({v[idx].S.F,v[idx].S.S});
      idx++;
    }
   
    while(!pq.empty() && pq.top().S<i)
      pq.pop();
    if(!pq.empty())
    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));
  idx=0;

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

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

    if(!pq.empty())
    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:31: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]
   31 |     while(idx<v.size() && v[idx].F==i)
      |           ~~~^~~~~~~~~
wall.cpp:61: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]
   61 |     while(idx<v.size() && v[idx].F==i)
      |           ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 195 ms 20144 KB Output is correct
3 Correct 99 ms 10208 KB Output is correct
4 Correct 199 ms 19248 KB Output is correct
5 Correct 208 ms 31640 KB Output is correct
6 Correct 194 ms 27264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -