# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538617 | 2022-03-17T08:56:49 Z | cig32 | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 159 ms | 9112 KB |
#include "bits/stdc++.h" using namespace std; const int MAXN = 2e5 + 10; const int MOD = 1e9 + 7; #define int long long #define ll __int128 mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } ll read() { // read int128 int x; cin >> x; return (ll)x; } long long bm(long long b, long long p) { if(p==0) return 1 % MOD; long long r = bm(b, p >> 1); if(p&1) return (((r*r) % MOD) * b) % MOD; return (r*r) % MOD; } long long inv(long long b) { return bm(b, MOD-2); } long long f[MAXN]; long long nCr(int n, int r) { long long ans = f[n]; ans *= inv(f[r]); ans %= MOD; ans *= inv(f[n-r]); ans %= MOD; return ans; } void precomp() { for(int i=0; i<MAXN; i++) f[i] = (i == 0 ? 1 % MOD : (f[i-1] * i) % MOD); } void solve(int tc) { int n, k, t; cin >> n >> k >> t; string s; cin >> s; vector<int> ans; int xorsum = 0; ans.push_back(0); vector<int> tog; int cur = (1<<k) - 1; for(int i=1; i<=n; i++) { tog.push_back(cur); if(cur >= (1 << (n-1))) { cur -= (1 << (n-1)); cur <<= 1; cur += 1; } else { cur <<= 1; } } for(int i=1; i<(1<<n); i++) { xorsum ^= tog[(int)log2(i & -i)]; ans.push_back(xorsum); } cout << (1<<n) << '\n'; int pos; int val = 0; for(int i=0; i<s.size(); i++) { val *= 2; val += (s[i] == '1'); } for(int i=0; i<ans.size(); i++) { if(ans[i] == val) pos = i; } for(int i=pos; i<pos+ans.size(); i++) { for(int j=n-1; j>=0; j--) { if(ans[i % (1<<n)] & (1<<j)) cout << "1"; else cout << "0"; } cout << '\n'; } } int32_t main(){ precomp(); ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for(int i=1; i<=t; i++) solve(i); } /* 7 14 19 25 28 7 14 7 19 7 14 7 25 7 14 7 19 7 14 7 28 7 14 7 19 7 14 7 25 7 14 7 19 7 14 7 0 7 12 11 6 1 10 13 3 4 15 8 5 2 9 14 7 12 1 15 8 3 14 0 7 12 1 15 8 3 14 7 (0111) 13 (1101) 11 (1011) 7 (0111) 14 (1110) 13 (1101) 14 (1110) 7 (0111) 14 (1110) 13 (1101) 11 (1011) 13 (1101) 7 (0111) 13 (1101) 14 (1110) */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1876 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1876 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 2132 KB | Found solution while it does not exist |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 154 ms | 9024 KB | Ok |
2 | Correct | 70 ms | 5404 KB | Ok |
3 | Correct | 3 ms | 1876 KB | Ok |
4 | Correct | 2 ms | 1876 KB | Ok |
5 | Correct | 3 ms | 1876 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1876 KB | Ok |
2 | Correct | 7 ms | 2132 KB | Ok |
3 | Correct | 80 ms | 5320 KB | Ok |
4 | Correct | 33 ms | 3624 KB | Ok |
5 | Incorrect | 3 ms | 1876 KB | The values in the output sequence are not pairwise distinct! |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 151 ms | 9056 KB | Ok |
2 | Correct | 142 ms | 9032 KB | Ok |
3 | Incorrect | 156 ms | 9016 KB | The values in the output sequence are not pairwise distinct! |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 154 ms | 9024 KB | Ok |
2 | Correct | 70 ms | 5404 KB | Ok |
3 | Correct | 3 ms | 1876 KB | Ok |
4 | Correct | 2 ms | 1876 KB | Ok |
5 | Correct | 3 ms | 1876 KB | Ok |
6 | Correct | 3 ms | 1876 KB | Ok |
7 | Correct | 7 ms | 2132 KB | Ok |
8 | Correct | 80 ms | 5320 KB | Ok |
9 | Correct | 33 ms | 3624 KB | Ok |
10 | Incorrect | 3 ms | 1876 KB | The values in the output sequence are not pairwise distinct! |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 79 ms | 5348 KB | Ok |
2 | Correct | 159 ms | 9112 KB | Ok |
3 | Correct | 152 ms | 8976 KB | Ok |
4 | Correct | 10 ms | 2388 KB | Ok |
5 | Correct | 3 ms | 1876 KB | Ok |
6 | Correct | 20 ms | 2808 KB | Ok |
7 | Correct | 146 ms | 9024 KB | Ok |
8 | Incorrect | 3 ms | 1876 KB | The values in the output sequence are not pairwise distinct! |
9 | Halted | 0 ms | 0 KB | - |