이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef unsigned long long ll;
vector <ll> fen(300002,0);
ll n, m;
ll sum(ll k){
ll s = 0;
while (k >= 1){
s += fen[k];
k -= k&-k;
}
return s;
}
void add(ll k, ll x){
while (k <= m + 2){
fen[k] += x;
k += k&-k;
}
}
int main()
{
cin >> n >> m;
vector <ll> o(m);
for (int i = 0; i < m; i++)
cin >> o[i];
vector <ll> p(n+1);
for (int i = 1; i <= n; i++)
cin >> p[i];
ll k;
cin >> k;
vector <pair <pair <ll,ll>,ll> > q(k);
vector <vector <ll> > stanice(n+1);
for (int i = 0; i < k; i++)
cin >> q[i].first.first >> q[i].first.second >> q[i].second;
for (int i = 0; i < m; i++)
stanice[o[i]].push_back(i+1);
vector <ll> lo(n+1,1);
vector <ll> hi(n+1,k+1);
vector <ll> rjesenja(n+1,-1);
ll rjeseni = 0;
while (rjeseni < n){
vector <pair<ll,ll> > mids(n+1);
for (int i = 1; i <= n; i++)
mids[i].first = (lo[i]+hi[i])/2, mids[i].second = i;
sort(mids.begin(), mids.end());
for (int i = 1; i <= m + 2; i++)
fen[i] = 0;
ll slid = 1;
for (int i = 0; i < k; i++){
ll li = q[i].first.first, de = q[i].first.second, w = q[i].second;
if (li <= de){
add(li, w), add(de + 1, -w);
} else {
add(li,w), add(m + 1, -w);
add(1, w), add(de + 1, -w);
}
while (slid <= n && mids[slid].first == i + 1){
ll pozi = mids[slid].second;
if (rjesenja[pozi] != -1){
slid++;
continue;
}
ll ima = 0;
for (int t = 0; t < stanice[pozi].size(); t++){
ll sta = stanice[pozi][t];
ima += sum(sta);
if (ima >= p[pozi])
break;
}
if (ima >= p[pozi]){
hi[pozi] = i + 1;
} else {
lo[pozi] = i + 2;
}
if (lo[pozi] >= hi[pozi])
rjeseni++, rjesenja[pozi] = lo[pozi];
slid++;
}
}
}
for (int i = 1; i <= n; i++){
if (rjesenja[i] == k + 1)
cout << "NIE" << endl;
else
cout << rjesenja[i] << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
met.cpp: In function 'int main()':
met.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
36 | for (int i = 0; i < m; i++)
| ~~^~~
met.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
39 | for (int i = 1; i <= n; i++)
| ~~^~~~
met.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
45 | for (int i = 0; i < k; i++)
| ~~^~~
met.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
47 | for (int i = 0; i < m; i++)
| ~~^~~
met.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
55 | for (int i = 1; i <= n; i++)
| ~~^~~~
met.cpp:58:27: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
58 | for (int i = 1; i <= m + 2; i++)
| ~~^~~~~~~~
met.cpp:61:27: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
61 | for (int i = 0; i < k; i++){
| ~~^~~
met.cpp:69:50: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
69 | while (slid <= n && mids[slid].first == i + 1){
met.cpp:71:36: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type' {aka 'long long unsigned int'} and 'int' [-Wsign-compare]
71 | if (rjesenja[pozi] != -1){
met.cpp:76:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | for (int t = 0; t < stanice[pozi].size(); t++){
| ~~^~~~~~~~~~~~~~~~~~~~~~
met.cpp:93:23: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
93 | for (int i = 1; i <= n; i++){
| ~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |