제출 #233272

#제출 시각아이디문제언어결과실행 시간메모리
233272kartelLjetopica (COI19_ljetopica)C++14
0 / 100
12 ms384 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #define F first #define S second #define pb push_back #define N +100500 #define M ll(1e9 + 7) #define sz(x) (int)x.size() #define re return #define oo ll(1e18) #define el '\n' #define pii pair <int, int> using namespace std; //using namespace __gnu_pbds; //typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef long long ll; typedef long double ld; ll sm(ll x, ll y) {return (x + y) % M;} ll bp(ll x, ll y) { if (y == 0) return 1ll; if (y % 2) return (bp(x, y - 1) * x) % M; ll a = bp(x, y / 2); return a * a % M; } int main() { srand(time(0)); ios_base::sync_with_stdio(0); iostream::sync_with_stdio(0); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); // in("input.txt"); // out("output.txt"); int n, k, i; ll ans; string s, a, b; cin >> n >> k; cin >> s; cin >> a; cin >> b; if (k == 0) { bitset <100500> bt; bt[0] = 1; i = 0; while (i < n - 1) { if (s[i] == 'L') { bitset <100500> nw; for (int i = 1; i <= n; i++) nw[i] = bt[i - 1]; bt = nw; } else { bitset <100500> nw; nw[0] = 1; for (int i = 1; i <= n; i++) nw[i] = bt[i - 1]; bt = nw; // for (int i = 0; i < n; i++) cout << bt[i]; } i++; } // cout << el; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); i = n - 1; while (i >= 0 && bt[i] == a[i] - '0') i--; // cerr << i << el; if (i < 0 || a[i] == '0') { i = n - 1; while (i >= 0 && bt[i] == a[i] - '0') i--; if (i < 0 || b[i] == '1') { i = 0; for (i = 0; i < n; i++) { if (bt[i]) ans = sm(ans, bp(2, i)); } } } for (i = 0; i < n; i++) bt[i] = 0; bt[0] = 1; i = 0; while (i < n - 1) { if (s[i] == 'R') { bitset <100500> nw; for (int i = 1; i <= n; i++) nw[i] = bt[i - 1]; bt = nw; } else { bitset <100500> nw; nw[0] = 1; for (int i = 1; i <= n; i++) nw[i] = bt[i - 1]; bt = nw; } i++; } reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); i = n - 1; while (i >= 0 && bt[i] == a[i] - '0') i--; if (i < 0 || a[i] == '0') { i = n - 1; while (i >= 0 && bt[i] == a[i] - '0') i--; if (i < 0 || b[i] == '1') { i = 0; for (i = 0; i < n; i++) { if (bt[i]) ans = sm(ans, bp(2, i)); } } } } cout << ans; }

컴파일 시 표준 에러 (stderr) 메시지

ljetopica.cpp: In function 'int main()':
ljetopica.cpp:134:36: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     if (bt[i]) ans = sm(ans, bp(2, i));
                                ~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...