# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
71498 | RezwanArefin01 | Linear Garden (IOI08_linear_garden) | C++17 | 38 ms | 10572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 1e6 + 10;
int f[N], n, M;
char s[N];
int main(int argc, char const *argv[]) {
scanf("%d %d", &n, &M);
scanf(" %s", s);
int len = strlen(s);
f[0] = 1;
for(int i = 1; i < N; i++)
f[i] = f[i - 1] * 2ll % M;
int idx = 1, bal = 0, mn = 0, mx = 0;
#define add(x, y) {x += y; if(x >= M) x -= M;}
#define sub(x, y) {x -= y; if(x < 0) x += M;}
for(int i = 0; i < len; i++) {
if(s[i] == 'L') {
mx = max(mx, ++bal);
} else {
int bal2 = bal + 1;
int mn2 = min(mn, bal2);
int mx2 = max(mx, bal2);
int rem = n - i - 1;
mn = min(mn, --bal);
if(mx2 - mn2 > 2) continue;
if(mx2 - mn2 == 2) {
if(mn2 < bal2 && bal2 < mx2){
add(idx, f[rem + 1 >> 1]);
} else add(idx, f[rem >> 1]);
} else {
add(idx, f[rem >> 1]);
add(idx, f[rem + 1 >> 1]);
sub(idx, 1);
}
}
}
printf("%d\n", idx);
}
컴파일 시 표준 에러 (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... |