| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 838144 | vjudge1 | Palembang Bridges (APIO15_bridge) | C++17 | 34 ms | 5992 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const long long cringe=1000000007;
#define se second
#define fi first
#define ll long long
#define ull unsigned long long
#define pll pair<long long, long long>
#define pii pair<int, int>
#define pub push_back
ll n,k, ans=0;
vector<ll> positions;
vector<pll> homeoff;
void solve(){
cin >> k >> n;
for(int i=0; i<n; i++){
char zonehome, zoneoff;
ll poshome, posoff;
cin >> zonehome >> poshome >> zoneoff >> posoff;
if(zonehome==zoneoff){
ans+=abs(poshome-posoff);
}else{
positions.pub(poshome);
positions.pub(posoff);
homeoff.pub(make_pair(poshome,posoff));
}
}
if(homeoff.size()<1){
cout << ans << endl;
return;
}
sort(positions.begin(),positions.end());
ll bridge=positions[positions.size()/2];
for(int i=0; i<homeoff.size(); i++){
ans+=abs(homeoff[i].fi-bridge)+abs(homeoff[i].se-bridge)+1;
}
cout << ans << endl;
return;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
solve();
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
