Submission #1240797
Source Code Expand
#include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> using namespace std; #define MAX 200002 int n; int v; vector<int> vv; int dp[MAX][20]; int val[MAX]; map<int, vector<int> > mp; vector<vector<int> > V; vector<int> VV; int mx = 0; int D[1 << 18]; bool ok(){ if (VV.size() == 0){ return true; } int N = VV.size(); for (int i = 1; i <= mx; i++){ dp[N - 1][i] = N - 1; } for (int i = N - 2; i >= 0; i--){ long long int d = VV[i + 1] - VV[i]; for (int j = 1; j <= mx; j++){ if (d <= val[j]){ dp[i][j] = dp[i + 1][j]; } else{ dp[i][j] = i; } } } memset(D, 0, sizeof(D)); for (int i = 0; i < (1 << mx); i++){ if (D[i] >= N){ return true; } for (int j = 1; j <= mx; j++){ if ((i >> (j - 1)) & 1)continue; int go = i | (1 << (j - 1)); D[go] = max(D[go], dp[D[i]][j]+1); } } return false; } bool ans[MAX]; int main(){ cin >> n >> v; for (int i = 0; i < n; i++){ int x; scanf("%d", &x); vv.push_back(x); } val[0] = v; for (mx = 1; v / 2 >= 0; mx++){ v /= 2; val[mx] = v; if (v == 0)break; } for (int i = 0; i <= mx; i++){ dp[n - 1][i] = n-1; } for (int i = n - 2; i >= 0; i--){ long long int d = vv[i + 1] - vv[i]; for (int j = 0; j <= mx; j++){ if (d <= val[j]){ dp[i][j] = dp[i + 1][j]; } else{ dp[i][j] = i; } } } for (int i = 0; i < n; i++){ mp[dp[i][0]].push_back(i); } if (mp.size()>mx+1){ } else{ for (auto it = mp.begin(); it != mp.end(); it++){ VV.clear(); for (int i = 0; i < n; i++){ if (i < (*it).second[0] || (*it).second.back() < i){ VV.push_back(vv[i]); } } if (ok()){ vector<int> &vvv = (*it).second; for (int j = 0; j < vvv.size(); j++){ ans[vvv[j]] = true; } } } } for (int i = 0; i < n; i++){ if (ans[i] == true){ puts("Possible"); } else{ puts("Impossible"); } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Camel and Oases |
User | Kmcode |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 2028 Byte |
Status | AC |
Exec Time | 419 ms |
Memory | 21636 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:66:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &x); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 2 ms | 1280 KB |
00_example_02.txt | AC | 2 ms | 1280 KB |
00_example_03.txt | AC | 2 ms | 1280 KB |
01.txt | AC | 251 ms | 3328 KB |
02.txt | AC | 56 ms | 1280 KB |
03.txt | AC | 225 ms | 1280 KB |
04.txt | AC | 46 ms | 1280 KB |
05.txt | AC | 87 ms | 1280 KB |
06.txt | AC | 279 ms | 6272 KB |
07.txt | AC | 73 ms | 3968 KB |
08.txt | AC | 251 ms | 3968 KB |
09.txt | AC | 55 ms | 3968 KB |
10.txt | AC | 107 ms | 3712 KB |
11.txt | AC | 145 ms | 4096 KB |
12.txt | AC | 195 ms | 3712 KB |
13.txt | AC | 376 ms | 21508 KB |
14.txt | AC | 285 ms | 1280 KB |
15.txt | AC | 64 ms | 1280 KB |
16.txt | AC | 242 ms | 1280 KB |
17.txt | AC | 29 ms | 1280 KB |
18.txt | AC | 6 ms | 1280 KB |
19.txt | AC | 143 ms | 1280 KB |
20.txt | AC | 267 ms | 4096 KB |
21.txt | AC | 55 ms | 3968 KB |
22.txt | AC | 216 ms | 4096 KB |
23.txt | AC | 60 ms | 4096 KB |
24.txt | AC | 8 ms | 3712 KB |
25.txt | AC | 120 ms | 3968 KB |
26.txt | AC | 132 ms | 4096 KB |
27.txt | AC | 369 ms | 21524 KB |
28.txt | AC | 288 ms | 4096 KB |
29.txt | AC | 74 ms | 3968 KB |
30.txt | AC | 286 ms | 4096 KB |
31.txt | AC | 111 ms | 3840 KB |
32.txt | AC | 212 ms | 3712 KB |
33.txt | AC | 152 ms | 3968 KB |
34.txt | AC | 214 ms | 3968 KB |
35.txt | AC | 419 ms | 21636 KB |
36.txt | AC | 310 ms | 1280 KB |
37.txt | AC | 66 ms | 1280 KB |
38.txt | AC | 242 ms | 1280 KB |
39.txt | AC | 66 ms | 1280 KB |
40.txt | AC | 11 ms | 1280 KB |
41.txt | AC | 143 ms | 1280 KB |
42.txt | AC | 76 ms | 1280 KB |
43.txt | AC | 134 ms | 1280 KB |
44.txt | AC | 293 ms | 1280 KB |
45.txt | AC | 85 ms | 1280 KB |
46.txt | AC | 60 ms | 3840 KB |
47.txt | AC | 301 ms | 3968 KB |
48.txt | AC | 150 ms | 3840 KB |
49.txt | AC | 79 ms | 3840 KB |
50.txt | AC | 149 ms | 3840 KB |
51.txt | AC | 282 ms | 3840 KB |
52.txt | AC | 141 ms | 3840 KB |
53.txt | AC | 318 ms | 3840 KB |
54.txt | AC | 141 ms | 3840 KB |
55.txt | AC | 268 ms | 3968 KB |
56.txt | AC | 50 ms | 3712 KB |
57.txt | AC | 24 ms | 3840 KB |
58.txt | AC | 136 ms | 3840 KB |
59.txt | AC | 73 ms | 3712 KB |
60.txt | AC | 151 ms | 3968 KB |
61.txt | AC | 266 ms | 3840 KB |
62.txt | AC | 133 ms | 3840 KB |
63.txt | AC | 284 ms | 3968 KB |
64.txt | AC | 142 ms | 3968 KB |
65.txt | AC | 269 ms | 3968 KB |
66.txt | AC | 2 ms | 1280 KB |
67.txt | AC | 2 ms | 1280 KB |