8892022-01-25 10:44:38kidesoRobotokcpp14Time limit exceeded 6/50493ms11392 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>

#define pii pair<int,int>

using namespace std;

ifstream f("be.txt");

vector <pii> x;
int N, M, K;

bool r(const pii &a,const pii &b) {
	if (a.second < b.second) return true;
	if (a.second > b.second) return false;
	return a.first < b.first;
}

int main()
{
	cin >> N >> M >> K;
	x.resize(K);
	for (auto& e : x) cin >> e.first >> e.second;

	sort(x.begin(), x.end(), r);

	int k = 0;
	while (!x.empty()) {
		vector<pii>::iterator it = x.begin();

		while (it != x.end()) {
			pii akt = *it;
			x.erase(it);
			it = x.begin();
			if (!x.empty()) {
				pii akt1 = *it;
				if (akt.second == akt1.second) continue;
				else {
					while (akt1.first < akt.first && it!=x.end()) {
						it = it + 1;
						if (it != x.end()) akt1 = *it;
					}
					if (akt.first <= akt1.first) continue;
					else it = x.end();
				}
			}
			else break;
		}

		++k;
	}

	cout << k << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/02ms1804 KiB
2Time limit exceeded0/0493ms2400 KiB
3Wrong answer0/21ms2836 KiB
4Wrong answer0/21ms2852 KiB
5Accepted2/21ms2848 KiB
6Wrong answer0/214ms2896 KiB
7Wrong answer0/29ms2916 KiB
8Wrong answer0/24ms2928 KiB
9Wrong answer0/24ms2944 KiB
10Accepted2/24ms2956 KiB
11Wrong answer0/2216ms3332 KiB
12Time limit exceeded0/2493ms2820 KiB
13Accepted2/22ms3476 KiB
14Time limit exceeded0/2405ms4488 KiB
15Time limit exceeded0/2439ms5640 KiB
16Time limit exceeded0/2405ms6804 KiB
17Time limit exceeded0/4409ms7940 KiB
18Time limit exceeded0/6449ms9164 KiB
19Time limit exceeded0/6425ms10244 KiB
20Time limit exceeded0/6442ms11392 KiB