Submission #1092013

#TimeUsernameProblemLanguageResultExecution timeMemory
1092013DeathIsAweToll (BOI17_toll)C++17
7 / 100
56 ms40792 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") int segment[131072]; void add(int pos, int a) { pos += 65536; segment[pos] = a; pos /= 2; while (pos > 0) { if (segment[2*pos + 1] == -1 || segment[2*pos] == -1) { segment[pos] = -1; } else { segment[pos] = segment[2*pos + 1] + segment[2*pos]; } pos /= 2; } } int find(int a, int b) { a += 65536; b += 65536 - 1; int val = 0; while (a <= b) { if (a % 2 == 1) { if (segment[a] == -1) { val = -1; break; } val += segment[a++]; } if (b % 2 == 0) { if (segment[b] == -1) { val = -1; break; } val += segment[b--]; } a /= 2; b /= 2; } if (val == 0) { return -1; } return val; } int main() { int k, n, m, o, d1, d2, t; cin >> k >> n >> m >> o; if (k == 1) { for (int i=0;i<131072;i++) { segment[i] = -1; } for (int i=0;i<m;i++) { cin >> d1 >> d2 >> t; add(d1, t); } for (int i=0;i<o;i++) { cin >> d1 >> d2; cout << find(d1, d2) << '\n'; } } int graph[(n + k - 1) / k][k][51][k]; for (int i=0;i<n+k-1;i++) { for (int j=0;j<k;j++) { for (int x=0;x<50;x++) { for (int y=0;y<k;y++) { graph[i][j][x][y] = 0; } } } } for (int i=0;i<m;i++) { cin >> d1 >> d2 >> t; graph[d1/k][d1%k][1][d2%k] = t; } }

Compilation message (stderr)

toll.cpp: In function 'int main()':
toll.cpp:63:9: warning: variable 'graph' set but not used [-Wunused-but-set-variable]
   63 |     int graph[(n + k - 1) / k][k][51][k];
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...