Submission #88888
Source Code Expand
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstring>
#include<stack>
#include<vector>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define T 1100000
int di[1100005],nkeb[1100005],nkek[1100005];
int n;
vector < int > v[2200005];
vector < pair < int , int > > qq,ww;
void oku(){
int i;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&di[i]);
}
stack < pair < int , int > > st;
void coz(){
int i,j,k;
for(i=1;i<=n;i++){
while(!st.empty() && st.top().f>di[i]){
nkek[st.top().s]=i-1;
st.pop();
}
st.push(mp(di[i],i));
}
while(!st.empty()){
nkek[st.top().s]=n;
st.pop();
}
for(i=n;i>=1;i--){
while(!st.empty() && st.top().f<di[i]){
nkeb[st.top().s]=i+1;
st.pop();
}
st.push(mp(di[i],i));
}
while(!st.empty()){
nkeb[st.top().s]=1;
st.pop();
}
for(i=1;i<=n;i++)
v[di[i]-i+T].push_back(i);
int a,b;
for(k=0;k<=2200000;k++)
for(i=0;i<v[k].size();i++)
for(j=i+1;j<v[k].size();j++){
a=v[k][i];
b=v[k][j];
if(nkeb[b]<=a && nkek[a]>=b)
qq.push_back(mp(a,b));
}
sort(qq.begin(),qq.end());
int mn=1000000000;
for(i=qq.size()-1;i>=0;i--){
if(mn>qq[i].s)
ww.push_back(qq[i]);
mn=min(mn,qq[i].s);
}
sort(ww.begin(),ww.end());
cout<<ww.size()<<endl;
for(i=0;i<ww.size();i++)
cout<<ww[i].f<<" "<<ww[i].s<<endl;
}
int main(){
oku();
coz();
return 0;
}
Submission Info
Submission Time
2013-07-07 15:15:14+0900
Task
15 - Empodia
User
halilozanakgul
Language
C++ (GCC 4.4.7)
Score
100
Code Size
1447 Byte
Status
AC
Exec Time
814 ms
Memory
75052 KB
Compile Error
./Main.cpp: In function ‘void oku()’:
./Main.cpp:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
Judge Result
Set Name
Set01
Set02
Set03
Set04
Set05
Set06
Set07
Set08
Set09
Set10
Set11
Set12
Set13
Set14
Set15
Set16
Set17
Set18
Set19
Set20
Score / Max Score
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
Status
Set Name
Test Cases
Set01
01
Set02
02
Set03
03
Set04
04
Set05
05
Set06
06
Set07
07
Set08
08
Set09
09
Set10
10
Set11
11
Set12
12
Set13
13
Set14
14
Set15
15
Set16
16
Set17
17
Set18
18
Set19
19
Set20
20
Case Name
Status
Exec Time
Memory
01
AC
136 ms
52688 KB
02
AC
161 ms
54724 KB
03
AC
154 ms
54752 KB
04
AC
139 ms
52568 KB
05
AC
132 ms
52572 KB
06
AC
136 ms
52676 KB
07
AC
142 ms
52540 KB
08
AC
132 ms
52536 KB
09
AC
128 ms
52584 KB
10
AC
136 ms
52568 KB
11
AC
146 ms
54716 KB
12
AC
178 ms
53828 KB
13
AC
169 ms
54080 KB
14
AC
169 ms
54080 KB
15
AC
155 ms
53476 KB
16
AC
150 ms
53568 KB
17
AC
169 ms
53688 KB
18
AC
520 ms
53192 KB
19
AC
665 ms
53560 KB
20
AC
814 ms
75052 KB