Submission #712090

#TimeUsernameProblemLanguageResultExecution timeMemory
712090PherokungLightning Rod (NOI18_lightningrod)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 10000005 #define F first #define S seconds int n,x[MAXN],y[MAXN],l[MAXN],r[MAXN],ans=0; vector<pair<int,int> > v; deque<int> dq; bool oper(pair<int,int> i,pair<int,int> j){ return i.F > j.F; } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&x[i],&y[i]); v.push_back({y[i],i}); } for(int i=1;i<=n;i++){ while(!dq.empty()){ int p = dq.front(); if(y[i] - x[i] >= y[p] - x[p]){ r[p] = i; dq.pop_front(); } else break; } dq.push_front(i); } while(!dq.empty()){ r[dq.front()] = n+1; dq.pop_front(); } for(int i=n;i>=1;i--){ while(!dq.empty()){ int p = dq.front(); if(y[i] + x[i] >= y[p] + x[p]){ l[p] = i; dq.pop_front(); } else break; } dq.push_front(i); } while(!dq.empty()){ l[dq.front()] = 0; dq.pop_front(); } memset(x,0,sizeof x); sort(v.begin(),v.end(),oper); for(auto tw : v){ int i = tw.S; if(!x[i] && !x[l[i]] && !x[r[i]]){ ans++; } x[i] = 1; } printf("%d",ans); }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:5:11: error: 'struct std::pair<int, int>' has no member named 'seconds'; did you mean 'second'?
    5 | #define S seconds
      |           ^~~~~~~
lightningrod.cpp:55:14: note: in expansion of macro 'S'
   55 |   int i = tw.S;
      |              ^
lightningrod.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
lightningrod.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d%d",&x[i],&y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~