# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054150 | 2024-08-12T07:01:04 Z | Rojus | Palembang Bridges (APIO15_bridge) | C++14 | 1 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; int main() { int k, n; cin >> k >> n; vector<pair<int, int>> v; vector<int> sarasas; set<int> s; int 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) { int ats=INT_MAX; for(int i=0; i<sarasas.size(); i++) { int 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); } cout << ats+priedas; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |