제출 #969520

#제출 시각아이디문제언어결과실행 시간메모리
969520batsukh2006Palembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms348 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> #include<numeric> #include<tuple> #include<bitset> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define MOD 1000000007 #define int long long #define ss second #define ff first #define endl '\n' #define ordered_set tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> signed main(){ // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k,n; cin>>k>>n; int sum=0; vector<pair<int,int> > v,d; for(int i=0; i<n; i++){ int s,t; char p,q; cin>>p>>s>>q>>t; if(p==q){ sum+=abs(s-t); }else{ sum++; v.push_back({s,i}); v.push_back({t,i}); d.push_back({s,t}); } } int sl=0,sr=0; // ordered_set f,s; vector<bool> vis(n); sort(v.begin(),v.end()); int ml=0,mr=v[v.size()/2].ff; for(int i=0; i<v.size(); i++){ sr+=abs(mr-v[i].ff); // s.insert({v[i].ff,v[i].ss}); } int res=sl+sr; if(k==1){ cout<<res+sum; }else{ // for(int i=0; i<v.size(); i++){ // if(!vis[v[i].ss]){ // vis[v[i].ss]=1; // s.erase({d[v[i].ss].ff,v[i].ss}); // s.erase({d[v[i].ss].ss,v[i].ss}); // f.insert({d[v[i].ss].ff,v[i].ss}); // f.insert({d[v[i].ss].ss,v[i].ss}); // int fh=f.size()/2,sh=s.size()/2; // int pl=(*f.find_by_order(fh)).ff; // int pr=(*s.find_by_order(sh)).ff; // sl+=abs(d[v[i].ss].ff-ml); // sl+=abs(d[v[i].ss].ss-ml); // sl+=fh*(pl-ml); // sl-=(f.size()-fh)*(pl-ml); // sr-=abs(d[v[i].ss].ff-mr); // sr-=abs(d[v[i].ss].ss-mr); // sr+=sh*(pr-mr); // sr-=(s.size()-sh)*(pr-mr); // ml=pl; // mr=pr; // res=min(res,sl+sr); // } // } // cout<<res+sum; } return 0; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:60:19: 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]
   60 |     for(int i=0; i<v.size(); i++){
      |                  ~^~~~~~~~~
bridge.cpp:59:9: warning: unused variable 'ml' [-Wunused-variable]
   59 |     int ml=0,mr=v[v.size()/2].ff;
      |         ^~
#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...