# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
76730 | farukkastamonuda | Lollipop (POI11_liz) | C++14 | 549 ms | 81652 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define li 1000005
using namespace std;
int n,m,lol[li*2],p,fk=-1,k;
char s[li];
vector<int> v;
bool naive(int k){
if(fk<0) return false;
if(~lol[fk]&&~lol[fk+k]){
printf("%d %d\n",lol[fk]+1,lol[fk+k]);
return true;
}
int bul=upper_bound(v.begin(),v.end(),k)-v.begin();
if(bul==(int)v.size()){
return false;
}
int l=v[bul];
if(~lol[l-k]&&lol[l]){
printf("%d %d\n",lol[l-k]+1,lol[l]);
return true;
}
return false;
}
int main(){
scanf("%d %d",&n,&m);
scanf("%s",s);
memset(lol,-1,sizeof(lol));
lol[0]=0;
for(int i=0;i<n;i++){
if(s[i]=='T'){
p+=2;
lol[p]=i+1;
}
else{
p+=1;
lol[p]=i+1;
v.push_back(p);
if(fk<0) fk=p;
}
}
for(int i=1;i<=m;i++){
scanf("%d",&k);
if(~lol[k]){
printf("1 %d\n",lol[k]);
}
else{
if(!naive(k)) printf("NIE\n");
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |