# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
36422 |
2017-12-09T01:21:12 Z |
imaxblue |
Editor (BOI15_edi) |
C++14 |
|
196 ms |
22564 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
int n, a[300005], t[300005], p[300005];
vector<pii> v, w;
vector<int> adj[300005];
bool u, b[300005];
void dfs(int N, int V){
p[N]=V;
fox(l, adj[N].size())
dfs(adj[N][l], V);
}
set<pii> s;
int main(){
scanf("%i", &n);
fox(l, n){
scanf("%i", &a[l]);
if (a[l]>0){
t[l]=a[l];
a[l]=0;
}
else a[l]=-a[l];
}
foxr(l, n){
u=1;
while(!w.empty() && w.back().x>a[l] && (v.empty() || v.back().y>w.back().y || v.back().x<=a[l])){
adj[l].pb(w.back().y);
w.pop_back();
}
if (!v.empty() && v.back().x>a[l]){
adj[l].pb(v.back().y);
u=0;
v.pop_back();
}
if (a[l]!=0){
if (u){
v.pb(mp(a[l], l));
} else {
w.pb(mp(a[l], l));
}
}
}
fox(l, n){
if (t[l]!=0){
dfs(l, l);
}
}
s.insert(mp(-1, 0));
fox(l, n){
if (b[p[l]]){
s.erase(mp(p[l], t[p[l]]));
} else {
s.insert(mp(p[l], t[p[l]]));
}
b[p[l]]=!b[p[l]];
//cout << p[l] << endl;
printf("%i\n", (--s.end())->y);
}
return 0;
}
Compilation message
edi.cpp: In function 'void dfs(int, int)':
edi.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
edi.cpp:33:5: note: in expansion of macro 'fox'
fox(l, adj[N].size())
^
edi.cpp: In function 'int main()':
edi.cpp:38:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i", &n);
^
edi.cpp:40:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i", &a[l]);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
12860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
17612 KB |
Output is correct |
2 |
Correct |
136 ms |
17612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
17888 KB |
Output is correct |
2 |
Correct |
133 ms |
21356 KB |
Output is correct |
3 |
Correct |
73 ms |
22564 KB |
Output is correct |
4 |
Correct |
136 ms |
17612 KB |
Output is correct |
5 |
Correct |
196 ms |
20516 KB |
Output is correct |
6 |
Correct |
96 ms |
17612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
12860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |