Submission #3438632
Source Code Expand
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; typedef long long LL; const int N = 2e5 + 50; const int mod = 1e9 + 7; struct Bit { #define lb(x) (x & (- x)) LL a[N]; Bit() { memset(a, 0, sizeof a); } inline void Add(int p, LL v) { for (; p < N; p += lb(p)) { a[p] += v; if (a[p] >= mod) a[p] -= mod; } } inline LL Sum(int p) { LL res = 0; for (; p > 0; p -= lb(p)) { res += a[p]; if (res >= mod) res -= mod; } return res; } } dp; int n, m; int a[N], b[N], tab[N]; int x[N], y[N]; vector <int> po[N]; bool tops[N]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i ++) scanf("%d", &a[i]); for (int i = 1; i <= m; i ++) scanf("%d", &b[i]); int k = n; n = 0; for (int i = 1, p = 0; i <= k; i ++) { if (a[i] <= b[1] || a[i] >= b[m]) continue; while (p <= m && a[i] >= b[p + 1]) p ++; if (b[p] == a[i]) continue; n ++; x[n] = a[i] - b[p]; y[n] = b[p + 1] - a[i]; } for (int i = 1; i <= n; i ++) { tab[i + i - 1] = x[i]; tab[i + i] = y[i]; } sort(tab + 1, tab + n + n + 1); k = unique(tab + 1, tab + n + n + 1) - tab - 1; for (int i = 1, p, q; i <= n; i ++) { p = lower_bound(tab + 1, tab + k + 1, x[i]) - tab; q = lower_bound(tab + 1, tab + k + 1, y[i]) - tab; po[p].push_back(q); } int Max = 0; for (int i = k; i; i --) { sort(po[i].begin(), po[i].end(), greater <int> ()); if (po[i].size() && po[i][0] >= Max) { tops[i] = 1; Max = po[i][0]; } } int ans = 0; for (int i = 1; i <= k; i ++) { if (tops) ans = (ans + dp.Sum(po[i][0] - 1) + 1) % mod; for (auto it : po[i]) dp.Add(it, dp.Sum(it - 1) + 1); } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Robots and Exits |
User | The_Unbeatable |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1878 Byte |
Status | RE |
Exec Time | 163 ms |
Memory | 13696 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:39:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); ^ ./Main.cpp:40:51: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (int i = 1; i <= n; i ++) scanf("%d", &a[i]); ^ ./Main.cpp:41:51: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (int i = 1; i <= m; i ++) scanf("%d", &b[i]); ^
Judge Result
Set Name | Sample | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 900 | ||||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 4 ms | 10368 KB |
0_01.txt | WA | 4 ms | 10368 KB |
0_02.txt | WA | 4 ms | 10368 KB |
0_03.txt | WA | 4 ms | 10368 KB |
0_04.txt | AC | 4 ms | 10368 KB |
1_00.txt | WA | 4 ms | 10368 KB |
1_01.txt | WA | 4 ms | 10368 KB |
1_02.txt | WA | 32 ms | 11004 KB |
1_03.txt | RE | 124 ms | 10752 KB |
1_04.txt | WA | 29 ms | 11904 KB |
1_05.txt | WA | 25 ms | 11392 KB |
1_06.txt | WA | 25 ms | 11392 KB |
1_07.txt | WA | 26 ms | 11392 KB |
1_08.txt | RE | 136 ms | 11008 KB |
1_09.txt | RE | 135 ms | 11008 KB |
1_10.txt | WA | 39 ms | 11008 KB |
1_11.txt | RE | 136 ms | 11008 KB |
1_12.txt | RE | 135 ms | 11008 KB |
1_13.txt | RE | 135 ms | 11008 KB |
1_14.txt | RE | 135 ms | 11008 KB |
1_15.txt | WA | 39 ms | 11008 KB |
1_16.txt | RE | 161 ms | 11520 KB |
1_17.txt | RE | 161 ms | 11520 KB |
1_18.txt | RE | 162 ms | 11520 KB |
1_19.txt | RE | 163 ms | 11520 KB |
1_20.txt | RE | 161 ms | 11520 KB |
1_21.txt | RE | 163 ms | 11520 KB |
1_22.txt | RE | 162 ms | 11520 KB |
1_23.txt | RE | 161 ms | 11520 KB |
1_24.txt | WA | 16 ms | 10368 KB |
1_25.txt | WA | 16 ms | 10368 KB |
1_26.txt | WA | 16 ms | 10368 KB |
1_27.txt | WA | 16 ms | 10368 KB |
1_28.txt | RE | 125 ms | 12416 KB |
1_29.txt | RE | 114 ms | 10880 KB |
1_30.txt | RE | 114 ms | 10752 KB |
1_31.txt | RE | 131 ms | 13056 KB |
1_32.txt | RE | 120 ms | 11264 KB |
1_33.txt | RE | 127 ms | 12160 KB |
1_34.txt | RE | 127 ms | 12288 KB |
1_35.txt | RE | 132 ms | 13184 KB |
1_36.txt | RE | 121 ms | 11520 KB |
1_37.txt | RE | 127 ms | 12416 KB |
1_38.txt | RE | 127 ms | 12544 KB |
1_39.txt | RE | 128 ms | 11776 KB |
1_40.txt | RE | 130 ms | 12800 KB |
1_41.txt | RE | 139 ms | 13696 KB |
1_42.txt | RE | 135 ms | 13184 KB |
1_43.txt | RE | 133 ms | 12928 KB |
1_44.txt | RE | 145 ms | 13696 KB |
1_45.txt | RE | 145 ms | 13696 KB |
1_46.txt | RE | 143 ms | 13696 KB |
1_47.txt | RE | 144 ms | 13696 KB |
1_48.txt | RE | 152 ms | 13568 KB |
1_49.txt | RE | 152 ms | 13568 KB |
1_50.txt | RE | 153 ms | 13568 KB |
1_51.txt | RE | 153 ms | 13568 KB |
1_52.txt | RE | 155 ms | 12928 KB |
1_53.txt | RE | 156 ms | 12928 KB |
1_54.txt | RE | 156 ms | 12928 KB |
1_55.txt | RE | 155 ms | 12928 KB |