Submission #519429

#TimeUsernameProblemLanguageResultExecution timeMemory
519429JomnoiLasers (NOI19_lasers)C++17
100 / 100
220 ms68500 KiB
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; using pii = pair <int, int>; const int N = 5e5+10; vector <int> laser[N]; vector <int> qs[N]; int ct[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int l, r; cin >> l >> r; for(int i = 1; i <= r; i++) { int x, y; cin >> x; while(x--) { cin >> y; laser[i].push_back(y); } qs[i].push_back(0); for(int j = 0; j < laser[i].size(); j++) { qs[i].push_back(qs[i].back()+laser[i][j]); } if(DEBUG) { cout << "\nDebug : "; for(auto v : qs[i]) { cout << v << " "; } cout << endl << endl; } } if(DEBUG) { cout << endl; } vector <pii> vec; for(int i = 1; i <= r; i++) { for(int j = 0; j < laser[i].size(); j++) { int left = qs[i][j]; int right = l-qs[i].back()+qs[i][j+1]; int range = right-left; if(DEBUG) { cout << "Debug : "; cout << left << " " << right << " " << 2*laser[i][j]-range << " " << range-laser[i][j] << endl; } if(2*laser[i][j]-range > 0) { vec.emplace_back(left+range-laser[i][j]+1, 1); vec.emplace_back(right-range+laser[i][j]+1, -1); } } if(DEBUG) { cout << endl; } } sort(vec.begin(), vec.end()); int ans = 0, sum = 0, left = -1; for(auto v : vec) { sum += v.second; if(left == -1) { left = v.first; } if(!sum) { ans += v.first-left; left = -1; } } cout << ans; return 0; }

Compilation message (stderr)

lasers.cpp: In function 'int main()':
lasers.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j = 0; j < laser[i].size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~~~
lasers.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j = 0; j < laser[i].size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...