Submission #2199942
Source Code Expand
#include <algorithm> #include <utility> #include <cstdio> #include <vector> #include <map> #define pb push_back #define mp std::make_pair #define MOD 1000000007 typedef long long ll; ll arr[205], rem[205]; std::vector<ll> vec; std::map<std::vector<ll>, std::vector<std::pair<ll, ll> > > app; inline int calc(ll l, ll r) { int res = 0; ll cur = 0; for (int i = 60; i >= 0; i--) { if ((l ^ r) & (1ll << i)) return res + 1 - (l == cur); if (l & (1ll << i)) { res++; cur |= 1ll << i; } } return res; } int main() { // freopen("ARC086-F.in", "r", stdin); int n; ll lim; scanf("%d%lld", &n, &lim); for (int i = 0; i < n; i++) scanf("%lld", arr + i); std::sort(arr, arr + n); for (int k = 0; k <= 60; k++) { for (int i = 0; i < n; i++) rem[i] = arr[i] & (1ll << k) - 1; std::sort(rem, rem + n); for (int i = 0; i < n; i++) { if (i && rem[i - 1] == rem[i]) continue; vec.clear(); ll mn = lim - k - calc((i ? rem[i - 1] : -1) + 1, rem[i]); for (int j = 0; j < n; j++) { ll res = (arr[j] >> k) - (rem[i] > (arr[j] & (1ll << k) - 1)); mn = std::min(mn, res); vec.pb(res); } if (mn < 0) continue; std::sort(vec.begin(), vec.end()); ll x = vec[0]; for (ll &j : vec) j -= x; app[vec].pb(mp(x - mn, x)); } } ll ans = 0; for (auto it : app) { std::sort(it.second.begin(), it.second.end()); ll l = 0, r = -1; for (auto x : it.second) { if (r < x.first) { ans += (r - l + 1) % MOD; l = x.first; } r = std::max(r, x.second); } ans += (r - l + 1) % MOD; } printf("%lld\n", ans % MOD); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Shift and Decrement |
User | diamond_duke |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 1736 Byte |
Status | AC |
Exec Time | 47 ms |
Memory | 16512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:34:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%lld", &n, &lim); ^ ./Main.cpp:36:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", arr + i); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All | sample1.txt, sample2.txt, sample3.txt, sample4.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 4.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 40 ms | 14208 KB |
10.txt | AC | 34 ms | 11776 KB |
11.txt | AC | 21 ms | 6272 KB |
12.txt | AC | 21 ms | 6016 KB |
13.txt | AC | 28 ms | 9216 KB |
14.txt | AC | 19 ms | 5376 KB |
15.txt | AC | 12 ms | 2560 KB |
16.txt | AC | 23 ms | 6784 KB |
17.txt | AC | 36 ms | 12544 KB |
18.txt | AC | 35 ms | 12032 KB |
19.txt | AC | 20 ms | 5888 KB |
2.txt | AC | 44 ms | 15744 KB |
20.txt | AC | 23 ms | 6272 KB |
21.txt | AC | 42 ms | 14592 KB |
22.txt | AC | 15 ms | 4480 KB |
23.txt | AC | 43 ms | 14848 KB |
24.txt | AC | 47 ms | 16384 KB |
25.txt | AC | 45 ms | 16000 KB |
26.txt | AC | 26 ms | 7808 KB |
27.txt | AC | 40 ms | 13824 KB |
28.txt | AC | 44 ms | 15744 KB |
29.txt | AC | 36 ms | 12544 KB |
3.txt | AC | 46 ms | 16512 KB |
30.txt | AC | 15 ms | 4864 KB |
31.txt | AC | 33 ms | 11008 KB |
32.txt | AC | 35 ms | 12032 KB |
33.txt | AC | 19 ms | 5504 KB |
34.txt | AC | 22 ms | 6656 KB |
35.txt | AC | 35 ms | 11904 KB |
36.txt | AC | 12 ms | 2560 KB |
37.txt | AC | 21 ms | 6272 KB |
38.txt | AC | 22 ms | 6528 KB |
39.txt | AC | 37 ms | 12416 KB |
4.txt | AC | 25 ms | 7808 KB |
40.txt | AC | 32 ms | 10752 KB |
41.txt | AC | 21 ms | 6272 KB |
42.txt | AC | 20 ms | 5632 KB |
43.txt | AC | 37 ms | 13184 KB |
44.txt | AC | 14 ms | 4352 KB |
5.txt | AC | 40 ms | 14080 KB |
6.txt | AC | 44 ms | 15488 KB |
7.txt | AC | 38 ms | 13824 KB |
8.txt | AC | 15 ms | 4480 KB |
9.txt | AC | 36 ms | 12416 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |
sample4.txt | AC | 1 ms | 384 KB |