Submission #134952

#TimeUsernameProblemLanguageResultExecution timeMemory
134952mirbek01Port Facility (JOI17_port_facility)C++11
0 / 100
2 ms376 KiB
# include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; struct st{ int a, b; } ar[N]; int n, fen[N + N]; void upd(int pos){ for(int i = pos; i < N + N; i |= i + 1) fen[i] ++; } int get(int r){ int ret = 0; for(int i = r; i > 0; i = (i & (i + 1)) - 1) ret += fen[i]; return ret; } int get(int l, int r){ return get(r) - get(l - 1); } int main(){ cin >> n; for(int i = 1; i <= n; i ++) scanf("%d %d", &ar[i].a, &ar[i].b); sort(ar + 1, ar + n + 1, [&](st a, st b){ return a.a < b.a;}); for(int i = 1; i <= n; i ++){ int cnt = get(ar[i].a, ar[i].b); if(cnt > 1){ cout << 0 << endl; return 0; } upd(ar[i].b); } }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &ar[i].a, &ar[i].b);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...