제출 #882610

#제출 시각아이디문제언어결과실행 시간메모리
882610vjudge1Palembang Bridges (APIO15_bridge)C++11
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #define all(aa) aa.begin(), aa.end() #define endl ("\n") #define pb push_back typedef long long ll; const int maxn = 1e5 + 5; using namespace std; int n, k; ll rem, cur, ans = LONG_LONG_MAX; vector<pair<ll, ll>> v; vector<ll> u; ll mindist(pair<ll, ll> p, ll l, ll r){ if( (p.first <= l && l <= p.second ) || (p.first <= r && r <= p.second) ) return 0; ll ret = min(abs(l - p.first), abs(l - p.second)); ret = min(ret, abs(r - p.first)); ret = min(ret, abs(r - p.second)); return 2*ret; } int main(){ cin >> k >> n; for(int i = 0; i < n; i++){ char c1, c2; int a, b; cin >> c1 >> a >> c2 >> b; if(a < b) swap(a, b); rem+= a - b; if(c1 != c2){ rem++; v.pb({b, a}); u.pb(a), u.pb(b); } } for(int l = 0; l < u.size(); l++){ for(int r = l; r < u.size(); r++){ cur = 0; for(auto p : v){ cur += mindist(p, l, r); } ans = min(ans, cur); } } cout << ans + rem << endl; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int l = 0; l < u.size(); l++){
      |                 ~~^~~~~~~~~~
bridge.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for(int r = l; r < u.size(); r++){
      |                  ~~^~~~~~~~~~
#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...