Submission #1054155

#TimeUsernameProblemLanguageResultExecution timeMemory
1054155RojusPalembang Bridges (APIO15_bridge)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int k, n; cin >> k >> n; vector<pair<int, int>> v; vector<int> sarasas; set<int> s; long long priedas=0; for(int i=0; i<n; i++) { char cg, cd; int ig, id; cin >> cg >> ig >> cd >> id; if(cg!=cd) { priedas++; v.push_back({ig, id}); if(s.find(ig)==s.end()) { s.insert(ig); sarasas.push_back(ig); } if(s.find(id)==s.end()) { s.insert(id); sarasas.push_back(id); } } else { priedas+=abs(ig-id); } } sort(sarasas.begin(), sarasas.end()); if(k==1) { long long ats=INT_MAX; for(int i=0; i<sarasas.size(); i++) { long long sum=0; for(int j=0; j<v.size(); j++) { sum+=abs(v[j].first-sarasas[i])+abs(v[j].second-sarasas[i]); } ats=min(ats, sum); } ats+=priedas; cout << ats; } return 0; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int i=0; i<sarasas.size(); i++)
      |                      ~^~~~~~~~~~~~~~~
bridge.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for(int j=0; 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...