답안 #76731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76731 2018-09-16T17:41:58 Z farukkastamonuda Lollipop (POI11_liz) C++14
100 / 100
595 ms 59032 KB
#include <bits/stdc++.h>
#define li 1000005
using namespace std;
int n,m,lol[li*4],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

liz.cpp: In function 'int main()':
liz.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
liz.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s);
     ~~~~~^~~~~~~~
liz.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15992 KB Output is correct
2 Correct 15 ms 16056 KB Output is correct
3 Correct 15 ms 16056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 16076 KB Output is correct
2 Correct 16 ms 16092 KB Output is correct
3 Correct 18 ms 16124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 16164 KB Output is correct
2 Correct 15 ms 16228 KB Output is correct
3 Correct 29 ms 16320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 16320 KB Output is correct
2 Correct 29 ms 16336 KB Output is correct
3 Correct 20 ms 16336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 16496 KB Output is correct
2 Correct 22 ms 16556 KB Output is correct
3 Correct 54 ms 17196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 17196 KB Output is correct
2 Correct 158 ms 19732 KB Output is correct
3 Correct 85 ms 19732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 19732 KB Output is correct
2 Correct 51 ms 19732 KB Output is correct
3 Correct 88 ms 19732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 19732 KB Output is correct
2 Correct 134 ms 19732 KB Output is correct
3 Correct 183 ms 20652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 22444 KB Output is correct
2 Correct 306 ms 22444 KB Output is correct
3 Correct 308 ms 24236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 261 ms 24236 KB Output is correct
2 Correct 324 ms 24528 KB Output is correct
3 Correct 381 ms 24704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 527 ms 27208 KB Output is correct
2 Correct 428 ms 27432 KB Output is correct
3 Correct 489 ms 34608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 595 ms 42480 KB Output is correct
2 Correct 453 ms 51024 KB Output is correct
3 Correct 423 ms 59032 KB Output is correct