제출 #1288961

#제출 시각아이디문제언어결과실행 시간메모리
1288961BlockOGLinear Garden (IOI08_linear_garden)C++20
100 / 100
134 ms1688 KiB
#include <bits/stdc++.h> // meeeooowwwww mrrowwww :3 // go play vivid/stasis!! now!!!! https://vividstasis.gay #define fo(i, a, b) for (auto i = (a); i < (b); i++) #define of(i, a, b) for (auto i = (b); i-- > (a);) #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define be(a) a.begin(), a.end() using namespace std; int ____init = []{ ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); return 0; }(); int main() { int n, m; cin >> n >> m; string s; cin >> s; array<array<int, 5>, 5> ol, ne, ol2, ne2; fo(i, 0, 5) fo(j, 0, 5) ol[i][j] = 0, ol2[i][j] = 0; if (s[0] == 'L') ol2[1][3] = 1; else ol[1][3] = 1, ol2[0][1] = 1; fo(i, 1, n) { fo(i, 0, 5) fo(j, 0, 5) ne[i][j] = 0, ne2[i][j] = 0; if (s[i] == 'L') { ne2[0][2] += ol2[0][1], ne2[1][3] += ol2[1][2], ne2[2][1] += ol2[2][0], ne2[2][2] += ol2[2][1], ne2[3][2] += ol2[3][1], ne2[3][3] += ol2[0][2] + ol2[3][2], ne2[4][3] += ol2[4][2], ne2[4][4] += ol2[1][3] + ol2[4][3]; } else { ne[0][2] += ol2[0][1], ne[1][3] += ol2[1][2], ne[2][1] += ol2[2][0], ne[2][2] += ol2[2][1], ne[3][2] += ol2[3][1], ne[3][3] += ol2[0][2] + ol2[3][2], ne[4][3] += ol2[4][2], ne[4][4] += ol2[1][3] + ol2[4][3]; ne2[0][1] += ol2[0][2], ne2[1][2] += ol2[1][3], ne2[2][0] += ol2[0][1] + ol2[2][1], ne2[2][1] += ol2[2][2], ne2[3][1] += ol2[1][2] + ol2[3][2], ne2[3][2] += ol2[3][3], ne2[4][2] += ol2[4][3], ne2[4][3] += ol2[4][4]; } ne[0][2] += ol[0][1], ne[1][3] += ol[1][2], ne[2][1] += ol[2][0], ne[2][2] += ol[2][1], ne[3][2] += ol[3][1], ne[3][3] += ol[0][2] + ol[3][2], ne[4][3] += ol[4][2], ne[4][4] += ol[1][3] + ol[4][3]; ne[0][1] += ol[0][2], ne[1][2] += ol[1][3], ne[2][0] += ol[0][1] + ol[2][1], ne[2][1] += ol[2][2], ne[3][1] += ol[1][2] + ol[3][2], ne[3][2] += ol[3][3], ne[4][2] += ol[4][3], ne[4][3] += ol[4][4]; fo(i, 0, 5) fo(j, 0, 5) ne[i][j] = ne[i][j] % m, ne2[i][j] = ne2[i][j] % m; swap(ol, ne), swap(ol2, ne2); } int res = 1; fo(i, 0, 5) fo(j, 0, 5) res = (res + ol[i][j]) % m; cout << res << endl; }
#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...