# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1054275 | 2024-08-12T08:19:59 Z | Rojus | Palembang Bridges (APIO15_bridge) | C++14 | 2000 ms | 12136 KB |
#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; vector<int> taskai; 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}); sarasas.push_back(ig); sarasas.push_back(id); if(s.find(ig)==s.end()) { s.insert(ig); taskai.push_back(ig); } if(s.find(id)==s.end()) { s.insert(id); taskai.push_back(id); } } else { priedas+=abs(ig-id); } } sort(sarasas.begin(), sarasas.end()); if(k==1) { int tiltas=sarasas.size()/2; long long sum=priedas; for(int i=0; i<v.size(); i++) { sum+=abs(v[i].first-sarasas[tiltas])+abs(v[i].second-sarasas[tiltas]); } cout << sum; } else { long long mins=LONG_MAX; for(int i=0; i<taskai.size()-1; i++) { for(int j=i+1; j<taskai.size(); j++) { long long sum=0; for(int k=0; k<v.size(); k++) { sum+=min(abs(v[k].first-taskai[i])+abs(v[k].second-taskai[i]), abs(v[k].first-taskai[j])+abs(v[k].second-taskai[j])); } mins=min(mins, sum); } } mins+=priedas; cout << mins; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 12 ms | 2248 KB | Output is correct |
13 | Correct | 80 ms | 12136 KB | Output is correct |
14 | Correct | 33 ms | 2432 KB | Output is correct |
15 | Correct | 45 ms | 7200 KB | Output is correct |
16 | Correct | 14 ms | 2248 KB | Output is correct |
17 | Correct | 57 ms | 11948 KB | Output is correct |
18 | Correct | 72 ms | 12036 KB | Output is correct |
19 | Correct | 70 ms | 11696 KB | Output is correct |
20 | Correct | 19 ms | 2244 KB | Output is correct |
21 | Correct | 55 ms | 12124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2025 ms | 344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2069 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2040 ms | 344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |