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>
#define ll long long
#define pb push_back
using namespace std;
const int maxN = 1e5+1;
int k, n;
struct Tbridge
{
char a, b;
ll x, y;
bool chk;
}p[maxN];
ll ans = 0;
void Input()
{
vector<ll> v;
cin >> k >> n;
for(int i = 1; i <= n; i++)
{
cin >> p[i].a >> p[i].x >> p[i].b >> p[i].y;
if(p[i].a == p[i].b)
{
ans += abs(p[i].y - p[i].x);
p[i].chk = false;
}
else
{
v.pb(p[i].x);
v.pb(p[i].y);
p[i].chk = true;
}
}
/* sort(v.begin(), v.end());
if(k == 1)
{
ll h = v.size()/2;
h = v[h];
for(int i = 1; i <= n; i++)
if(p[i].chk)
ans += abs(h - p[i].x) + abs(h - p[i].y) + 1;
cout << ans;
return;
}
/* int res = v.size()/3;
int h = v[res], h2 = v[res*2];
for(int i = 1; i <= n; i++)
if(p[i].chk)
ans += min(abs(h - p[i].x) + abs(h - p[i].y) + 1, abs(h2 - p[i].x) + abs(h2 - p[i].y) + 1);
cout << ans;*/
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
Input();
}
Compilation message (stderr)
bridge.cpp:45:4: warning: "/*" within comment [-Wcomment]
45 | /* int res = v.size()/3;
|
# | 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... |