제출 #120014

#제출 시각아이디문제언어결과실행 시간메모리
120014E869120Editor (BOI15_edi)C++14
15 / 100
3044 ms34616 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <queue> #include <functional> using namespace std; #pragma warning (disable: 4996) int N, A[1 << 19], G[1 << 19], level[1 << 19], par[1 << 19], maxlevel = 0; vector<int>I[1 << 19]; set<int>Set; priority_queue<int, vector<int>, less<int>> Q; int main() { scanf("%d", &N); for (int i = 1; i <= N; i++) { scanf("%d", &A[i]); level[i] = max(0, -A[i]); maxlevel = max(maxlevel, level[i]); I[level[i]].push_back(i); } for (int i = 1; i <= N; i++) Set.insert(i); for (int i = maxlevel; i >= 1; i--) { set<int>Set2; for (int j = 0; j < I[i].size(); j++) { auto itr = Set.lower_bound(I[i][j]); if (itr != Set.end() && (*itr) == I[i][j]) { Set.erase(I[i][j]); Set2.insert(I[i][j]); } } for (int j = 0; j < I[i].size(); j++) { auto itr = Set.lower_bound(I[i][j]); itr--; par[I[i][j]] = (*itr); auto itr2 = Set2.lower_bound(I[i][j]); if (itr2 != Set2.end() && (*itr2) == I[i][j]) Set.erase(par[I[i][j]]); } } Q.push(0); G[0] = 1; for (int i = 1; i <= N; i++) { if (A[i] > 0) { G[i] = 1; Q.push(i); } else { G[i] = 1; int cx = i; while (par[cx] != 0) { cx = par[cx]; G[cx] ^= 1; } Q.push(cx); while (!Q.empty()) { int pos = Q.top(); if (G[pos] == 0) Q.pop(); else break; } } int ans = Q.top(); printf("%d\n", A[ans]); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

edi.cpp:8:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
edi.cpp: In function 'int main()':
edi.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < I[i].size(); j++) {
                   ~~^~~~~~~~~~~~~
edi.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < I[i].size(); j++) {
                   ~~^~~~~~~~~~~~~
edi.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
edi.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...