# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251298 | jimmy123 | Lollipop (POI11_liz) | C++14 | 529 ms | 18556 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 <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_NUM = 1000000;
char data[MAX_NUM+1];
int location[2*MAX_NUM+1]={0};
int main(){
int num=0, query=0, cnt=1, pos=0, first_W=-1, last_W=-1, range, i, add;
bool isfirst = true;
scanf("%d%d%s", &num, &query, data);
vector<int> Wpos;
for(i=0;i<num;++i){
if(data[i] == 'W'){
pos += 1;
last_W = pos;
if(isfirst){
first_W = pos;
Wpos.push_back(pos);
isfirst = false;
}
if(add > 1000){
Wpos.push_back(pos);
add = 0;
}
}
else
pos += 2;
location[pos] = cnt;
cnt += 1;
add += 1;
}
Wpos.push_back(last_W);
for(i=0;i<query;++i){
if(i != 0)
printf("\n");
scanf("%d", &range);
if(location[range] != 0){
printf("1 %d", location[range]);
continue;
}
int idx = upper_bound(Wpos.begin(), Wpos.end(), range) - Wpos.begin();
//if(last_W != -1 && last_W > range){
if(idx != Wpos.size()){
if(location[Wpos[idx]-range] != 0){
printf("%d %d", location[Wpos[idx]-range]+1, location[Wpos[idx]]);
continue;
}
else if(location[Wpos[idx]-range-1] != 0){
printf("%d %d", location[Wpos[idx]-range-1]+1, location[Wpos[idx]-1]);
continue;
}
}
if(first_W != -1 && first_W < range){
if(location[first_W+range] != 0){
printf("%d %d", location[first_W]+1, location[first_W+range]);
continue;
}
else if(location[first_W+range-1] != 0){
printf("%d %d", location[first_W-1]+1, location[first_W+range-1]);
continue;
}
}
// 找不到解
printf("NIE");
}
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... |