제출 #347684

#제출 시각아이디문제언어결과실행 시간메모리
347684saral새로운 문제 (POI11_met)C++14
100 / 100
4035 ms40288 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int const int N = 300100; int t, n, m; vector<int>states[N], pos, v; lli tour[N*6], ness[N], OFF, sol[N], a, Q; pair<pair<lli, lli>, lli> q[N]; void update (int l, int r, int x, int y, int node, lli value) { if (x <= l && r <= y) { tour[node]+=value; return; } if (r < x || l > y) return; int mid = (l+r)/2; update (l, mid, x, y, node*2, value); update (mid+1, r, x, y, node*2+1, value); return; } lli get (int x) { lli rez=0; x = x+OFF-1; rez += tour[x]; x/=2; while (x) { rez+=tour[x]; x/=2; } return rez; } void f (int l, int r, vector<int> pos) { /*cout << l << " " << r << endl; for(int i = 0; i < pos.size(); i++){ cout << pos[i] << " "; } cout<< endl; system("pause");*/ int lb, rb; lli val; if (l==r) { for (int i = 0; i < pos.size(); i++) { sol[pos[i]]=l; } return; } int mid = (l+r)/2; vector<int>left; vector<int>right; for (int i = l; i <= mid; i++) { lb = q[i].first.first, rb = q[i].first.second, val = q[i].second; if (lb <= rb) { update (1, OFF, lb, rb, 1, val); } else { update (1, OFF, lb, m, 1, val); update (1, OFF, 1, rb, 1, val); } } for (int i = 0; i < pos.size(); i++) { lli zbr = 0; for (int j = 0; j < states[pos[i]].size(); j++) { zbr += get (states[pos[i]][j]); if (zbr >= 1e10) break; } if (zbr >= ness[pos[i]]) { left.push_back(pos[i]); } else right.push_back(pos[i]); //cout << pos[i] << " " << zbr << endl; } //cout << endl; f (mid+1, r, right); for (int i = l; i <= mid; i++) { lb = q[i].first.first, rb = q[i].first.second, val = q[i].second; if (lb <= rb) { update (1, OFF, lb, rb, 1, -val); } else { update (1, OFF, lb, m, 1, -val); update (1, OFF, 1, rb, 1, -val); } } f (l, mid, left); return; } void solve () { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a; states[a].push_back(i); } OFF=1; while (OFF < m) OFF*=2; for (int i = 1; i <= n; i++) cin >> ness[i]; cin >> Q; for (int i = 1; i <= Q; i++) cin >> q[i].first.first >> q[i].first.second >> q[i].second; for (int i = 1; i <= n; i++) v.push_back(i); f (1, Q+1, v); for (int i = 1; i <= n; i++) { if (sol[i] > Q) cout << "NIE\n"; else cout << sol[i] << "\n"; } return; } int main () { solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

met.cpp: In function 'void f(int, int, std::vector<int>)':
met.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for (int i = 0; i < pos.size(); i++) {
      |                         ~~^~~~~~~~~~~~
met.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int i = 0; i < pos.size(); i++) {
      |                     ~~^~~~~~~~~~~~
met.cpp:69:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         for (int j = 0; j < states[pos[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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...