제출 #102260

#제출 시각아이디문제언어결과실행 시간메모리
102260TAMREFLinear Garden (IOI08_linear_garden)C++11
100 / 100
203 ms4380 KiB
#include <bits/stdc++.h> using namespace std; int d[2][32]; unsigned char bi[1000005], ci[1000005]; int n, m; int ans = 1; string S; void add(int &x, int y){ x = (x + y) % m; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin >> n >> m >> S; for(int i = 1; i <= n; i++){ if(S[i-1] == 'L'){ bi[i] = bi[i-1] << 1 | 8; }else{ bi[i] = bi[i-1] >> 1 | 2; ci[i] = bi[i-1] << 1 | 8; } } for(int i = 0; i < 32; i++) d[0][i] = 1; if(S[n-1] == 'P' && ci[n] < 32) add(ans, 1); for(int i = 1, w = 1; i < n; i++, w = !w){ for(int b = 0; b < 32; b++) d[w][b] = 0; for(int b = 0; b < 32; b++){ if((b & 1) == 0){ add(d[w][b], d[!w][b >> 1 | 2]); } if((b & 16) == 0){ add(d[w][b], d[!w][b << 1 | 8]); } } if(S[n-1-i] == 'P' && ci[n-i] < 32) add(ans, d[w][ci[n-i]]); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...