Submission #389782

#TimeUsernameProblemLanguageResultExecution timeMemory
389782milleniumEeeePalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms460 KiB
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long
using namespace std;

const int MAXN = (int)2e5 + 5;
const int INF = 1e18;

pair <char, int> st[MAXN];
pair <char, int> fn[MAXN];

bool ok(int pos) {
	return (st[pos].first == fn[pos].first);	
}

vector <int> vec;

int check(int pos) {
	int sum = 0;
	for (int el : vec) {
		sum += abs(el - pos);
	}
	return sum;
}

signed main() {
	fastInp;
	int n, k;
	cin >> k >> n;
	for (int i = 1; i <= n; i++) {
		cin >> st[i].fr >> st[i].sc >> fn[i].fr >> fn[i].sc;
	}
	if (k == 1) {
		int side = 0;
		vector <int> x;
		for (int i = 1; i <= n; i++) {
			if (ok(i)) {
				side += abs(st[i].sc - fn[i].sc);
			} else {
				x.pb(st[i].sc);
				x.pb(fn[i].sc);
			}
		}
		sort(all(x));
		cout << side + (szof(x) / 2) + x[szof(x) / 2 - 1] << endl;
	}
	else if (k == 2) {
		
	}
}

/*
2 5
B 0 A 4
B 1 B 3
A 5 B 7
B 2 A 6
B 1 A 7
*/
#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...