Submission #1060640

#TimeUsernameProblemLanguageResultExecution timeMemory
1060640oviyan_gandhiLightning Rod (NOI18_lightningrod)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; inline int readInt() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = _getchar_nolock(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = _getchar_nolock(); } return x; } int X[10000000], Y[10000000]; bool use[10000000]; // whether i contains j bool contains(int i, int j){ return abs(X[i] - X[j]) <= (Y[i] - Y[j]); } int main(){ int N = readInt(); for(int i = 0; i < N; i++) { X[i] = readInt(); Y[i] = readInt(); use[i] = true; } stack<int> s; for (int i = 0; i < N; i++){ while (!s.empty() && !contains(s.top(), i)) s.pop(); if (!s.empty()) use[i] = false; s.push(i); } while (!s.empty()) s.pop(); for (int i = N-1; i >= 0; i--){ while (!s.empty() && !contains(s.top(), i)) s.pop(); if (!s.empty()) use[i] = false; s.push(i); } cout << accumulate(use, use+N, 0) << '\n'; return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int readInt()':
lightningrod.cpp:7:39: error: '_getchar_nolock' was not declared in this scope; did you mean 'getchar_unlocked'?
    7 |     while (ch < '0' || ch > '9') ch = _getchar_nolock();
      |                                       ^~~~~~~~~~~~~~~
      |                                       getchar_unlocked
lightningrod.cpp:10:8: error: '_getchar_nolock' was not declared in this scope; did you mean 'getchar_unlocked'?
   10 |   ch = _getchar_nolock();
      |        ^~~~~~~~~~~~~~~
      |        getchar_unlocked