Submission #56464

# Submission time Handle Problem Language Result Execution time Memory
56464 2018-07-11T12:23:28 Z ramchandra Lollipop (POI11_liz) C++14
82 / 100
2000 ms 100408 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);
	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);
	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){
			//assert(is[j] == -1);
			is[j] = i;
			//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];
			}
		}
		if(l!=-1){
			cout<<l+1<<" "<<r+1<<endl;
		}
		else {
			cout<<"NIE"<<endl;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 7 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 756 KB Output is correct
2 Correct 3 ms 756 KB Output is correct
3 Correct 3 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 824 KB Output is correct
2 Correct 4 ms 828 KB Output is correct
3 Correct 54 ms 1304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1304 KB Output is correct
2 Correct 26 ms 1332 KB Output is correct
3 Correct 27 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1984 KB Output is correct
2 Correct 59 ms 2244 KB Output is correct
3 Correct 249 ms 3760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 173 ms 4740 KB Output is correct
2 Correct 747 ms 9944 KB Output is correct
3 Correct 416 ms 9944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 9944 KB Output is correct
2 Correct 214 ms 9944 KB Output is correct
3 Correct 409 ms 12540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 569 ms 15636 KB Output is correct
2 Correct 610 ms 17688 KB Output is correct
3 Correct 847 ms 23344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1284 ms 33848 KB Output is correct
2 Correct 1185 ms 37784 KB Output is correct
3 Correct 1354 ms 46788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1094 ms 50412 KB Output is correct
2 Correct 1535 ms 57148 KB Output is correct
3 Correct 1564 ms 66724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 83904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1986 ms 95872 KB Output is correct
2 Execution timed out 2063 ms 100408 KB Time limit exceeded
3 Halted 0 ms 0 KB -