Submission #197443

# Submission time Handle Problem Language Result Execution time Memory
197443 2020-01-21T09:01:50 Z quocnguyen1012 Lightning Rod (NOI18_lightningrod) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  int N = in;
  stack<pair<int, int>> ST;
  while (N--){
    int x = in, y = in;
    bool ok = 1;
    while (ST.size()){
      auto now = ST.top();
      if (x - now.fi <= now.se - y){
        ok = false;
        break;
      }
      else if (x - now.fi <= y - now.se){
        ST.pop();
      }
      else break;
    }
    if (ok){
      dq.push(mp(x, y));
    }
  }
  cout << (int)dq.size() << '\n';
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:37:7: error: 'dq' was not declared in this scope
       dq.push(mp(x, y));
       ^~
lightningrod.cpp:40:16: error: 'dq' was not declared in this scope
   cout << (int)dq.size() << '\n';
                ^~
lightningrod.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.INP", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
lightningrod.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.OUT", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~