# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56484 |
2018-07-11T12:56:18 Z |
ramchandra |
Lollipop (POI11_liz) |
C++14 |
|
2000 ms |
42212 KB |
#include <bits/stdc++.h>
#define in(x) ll x;cin>>x;
#define al(x) x.begin(),x.end()
#define vc vector
#define fo(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using ll = int; // mem
int main(){
cin.sync_with_stdio(false);
cout.sync_with_stdio(false);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
in(n);in(m);
//vc<ll> ar(2*n+50,-1);
//vc<ll> ps(2*n+50,-1);
//vc<ll> is(2*n+50,-1);
const ll BIG=2e6+50;
#define DF(zz) ll zz[BIG];fill(zz,zz+BIG,-1);
DF(ar);
DF(ps);
DF(is);
DF(ls);
ll cnt = 0;
ll fst = -1;
fo(i,0,n){
char c;cin>>c;
bool tp = (c=='T');
if(fst==-1 && !tp){fst = cnt;}
ar[cnt]=i;
ps[i]=cnt;
cnt++; cnt+=tp;
}
if(fst==-1){fst = cnt;}
ar[cnt] = n;
ps[n] = cnt;
ll sz = ar[fst];
ll c[2] = {2,1};
fo(i,ar[fst]-1,n){
ll v = ps[i+1]-fst;
//cout<<v<<" "<<c[v%2]<<endl;
for(ll j = max(v,c[v%2]); j <= min((ll)(2*n),v+2*sz); j+=2){
if(is[j] != -1){abort();}
is[j] = i;
ls[j] = ar[v+fst-j];
//cerr<<"oh "<<j<<" "<<i<<endl;
}
c[v%2] = v+2*sz+2;
}
/*fo(i,1,sz+1){
is[2*i] = ar[fst]-1;
}*/
fo(z,0,m){
in(k);
ll l=-1,r=-1;
if(fst+k<=cnt){
if(ar[fst+k]==-1){
l = ar[fst]+1;
r = ar[fst+k-1];
}
else{
l = ar[fst];
r = ar[fst+k]-1;
}
}
else {
if(is[k]!=-1){
r = is[k];
//l = ar[ps[r+1]-k];
l = ls[k];
}
}
if(l!=-1){
cout<<l+1<<" "<<r+1<<endl;
}
else {
cout<<"NIE"<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
31608 KB |
Output is correct |
2 |
Correct |
38 ms |
31844 KB |
Output is correct |
3 |
Correct |
32 ms |
31844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
31844 KB |
Output is correct |
2 |
Correct |
38 ms |
31844 KB |
Output is correct |
3 |
Correct |
38 ms |
31844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
31844 KB |
Output is correct |
2 |
Correct |
34 ms |
31844 KB |
Output is correct |
3 |
Correct |
74 ms |
31864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
31864 KB |
Output is correct |
2 |
Correct |
62 ms |
31976 KB |
Output is correct |
3 |
Correct |
62 ms |
32068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
32092 KB |
Output is correct |
2 |
Correct |
71 ms |
32092 KB |
Output is correct |
3 |
Correct |
312 ms |
33016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
281 ms |
33016 KB |
Output is correct |
2 |
Correct |
1020 ms |
35704 KB |
Output is correct |
3 |
Correct |
498 ms |
35704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
35704 KB |
Output is correct |
2 |
Correct |
271 ms |
35704 KB |
Output is correct |
3 |
Correct |
552 ms |
35704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
791 ms |
35704 KB |
Output is correct |
2 |
Correct |
833 ms |
35704 KB |
Output is correct |
3 |
Correct |
1058 ms |
36500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1539 ms |
39344 KB |
Output is correct |
2 |
Correct |
1571 ms |
39344 KB |
Output is correct |
3 |
Correct |
1889 ms |
40524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1434 ms |
40524 KB |
Output is correct |
2 |
Correct |
1914 ms |
40524 KB |
Output is correct |
3 |
Execution timed out |
2104 ms |
40524 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2017 ms |
40524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2088 ms |
42212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |