제출 #905115

#제출 시각아이디문제언어결과실행 시간메모리
905115Ahmed57Reconstruction Project (JOI22_reconstruction)C++17
7 / 100
1595 ms64184 KiB
//#include "dango3.h" #include <bits/stdc++.h> using namespace std; #define int long long signed main(){ //freopen("input.txt","r",stdin); //freopen("outout.txt","w",stdout); int n,m; cin>>n>>m; vector<int> v[n]; int cool[n]; long long smaller =0 , greater = 0; long long cntsm = 0 , cntlr = 0; for(int i = 0;i<m;i++){ int a,b,c; cin>>a>>b>>c; v[a].push_back(c); } vector<pair<int,int>> pts; for(int i = 1;i<n;i++){ sort(v[i].begin(),v[i].end()); pts.push_back({0,i}); for(int j = 0;j<v[i].size();j++){ pts.push_back({v[i][j]+1,i}); pts.push_back({v[i][j],i}); } for(int j = 1;j<v[i].size();j++){ pts.push_back({(v[i][j]+v[i][j-1])/2+1,i}); pts.push_back({(v[i][j]+v[i][j-1])/2,i}); } cool[i] = 0; } sort(pts.begin(),pts.end()); int q; cin>>q; long long ans[q]; vector<pair<int,int>> qu; for(int i = 0;i<q;i++){ int c;cin>>c; qu.push_back({c,i}); } sort(qu.begin(),qu.end()); int ind = 0; for(auto i:qu){ while(ind<pts.size()&&pts[ind].first<=i.first){ int an = pts[ind].second; if(cool[an]!=0){ if(cool[an]>0){ greater-=cool[an]; cntlr--; }else{ smaller+=cool[an]; cntsm--; } } int it = lower_bound(v[an].begin(),v[an].end(),i.first)-v[an].begin(); if(it==v[an].size()){ it--; cool[an] = -v[an][it]; smaller+=v[an][it]; cntsm++; }else if(it==0){ cool[an] = v[an][it]; greater+=v[an][it]; cntlr++; }else{ if(abs(v[an][it]-i.first)<=abs(v[an][it-1]-i.first)){ cool[an] = v[an][it]; greater+=v[an][it]; cntlr++; }else{ it--; cool[an] = -v[an][it]; smaller+=v[an][it]; cntsm++; } } ind++; } ans[i.second] = greater-smaller-i.first*cntlr+i.first*cntsm; } for(int i = 0;i<q;i++){ cout<<ans[i]<<endl; } }

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

reconstruction.cpp: In function 'int main()':
reconstruction.cpp:24:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j = 0;j<v[i].size();j++){
      |                       ~^~~~~~~~~~~~
reconstruction.cpp:28:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j = 1;j<v[i].size();j++){
      |                       ~^~~~~~~~~~~~
reconstruction.cpp:46:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         while(ind<pts.size()&&pts[ind].first<=i.first){
      |               ~~~^~~~~~~~~~~
reconstruction.cpp:58:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             if(it==v[an].size()){
      |                ~~^~~~~~~~~~~~~~
#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...