# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
337312 | Giselus | Linear Garden (IOI08_linear_garden) | C++14 | 47 ms | 6368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int pot[1000007];
int main(void){
int n,m,a,b,c,d,x;
int ma = 0, mi = 0;
string s;
scanf("%d %d",&n,&m);
cin >> s;
pot[0] = 1;
for(int i = 1; i<=n+3;i++){
pot[i] = pot[i-1] * 2;
pot[i] %= m;
}
int odp = 0;
int cur = 0;
for(int i =1; i <= n;i++){
if(s[i-1] == 'L'){
cur++;
ma = max(ma,cur);
}else{
cur--;
if(cur == -2){
if(mi == -2){
odp += pot[(n-i)/2];
}else{
odp += pot[(n-i)/2];
odp += pot[(n-i+1)/2]-1;
}
}
if(cur == -1 && mi == -1){
odp += pot[(n-i)/2];
}
if(cur == -1 && mi == 0){
odp += pot[(n-i)/2];
odp += pot[(n-i+1)/2]-1;
}
if(cur == 0 && mi == 0){
odp += pot[(n-i)/2];
}
mi = min(mi,cur);
//printf("%d %d\n",i,odp);
odp %= m;
}
}
odp++;
odp %= m;
printf("%d",odp);
return 0;
}
컴파일 시 표준 에러 (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... |
# | 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... |