제출 #106984

#제출 시각아이디문제언어결과실행 시간메모리
106984someone_aaPalembang Bridges (APIO15_bridge)C++17
17 / 100
2056 ms3812 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 100100; ll s[maxn], f[maxn], n, k; char szone[maxn], fzone[maxn]; int main() { cin>>k>>n; ll result = 0LL; vector<ll>v; for(int i=1;i<=n;i++) { cin>>szone[i]>>s[i]; cin>>fzone[i]>>f[i]; if(szone[i] == fzone[i]) result += abs(f[i] - s[i]); v.pb(s[i]); v.pb(f[i]); } if(k == 1) { ll mintemp = LLONG_MAX; for(int i:v) { ll temp = 0LL; for(int j=1;j<=n;j++) { if(szone[j] != fzone[j]) { temp += abs(s[j] - i) + abs(f[j] - i) + 1; } } mintemp = min(mintemp, temp); //cout<<i<<": "<<temp<<"\n"; } result += mintemp; cout<<result<<"\n"; return 0; } else if(k == 2) { ll mintemp = LLONG_MAX; for(int i=0;i<v.size();i++) { for(int j=i+1;j<v.size();j++) { ll temp = 0LL; for(int d=1;d<=n;d++) { if(szone[d] != fzone[d]) { temp += min(abs(f[d] - v[i]) + abs(s[d] - v[i]), abs(f[d] - v[j]) + abs(s[d] - v[j])) + 1LL; } } mintemp = min(mintemp, temp); } } result += mintemp; cout<<result<<"\n"; return 0; } return 0; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:41:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<v.size();i++) {
                     ~^~~~~~~~~
bridge.cpp:42:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=i+1;j<v.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...