Submission #1027944

# Submission time Handle Problem Language Result Execution time Memory
1027944 2024-07-19T11:52:04 Z mansur Tiles (BOI24_tiles) C++17
4 / 100
36 ms 2248 KB
#include<bits/stdc++.h>

using namespace std;

#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second
#define f first

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int N = 1e6;
const int inf = 1e9;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> x = {-1}, y = {-1};
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		if (sz(x) > 2) {
			if (x[sz(x) - 2] == x[sz(x) - 1] && x[sz(x) - 1] == a) x.pop_back();
			else if (y[sz(y) - 2] == y[sz(y) - 1] && y[sz(y)  -1] == b) y.pop_back();
		}
		x.push_back(a);
		y.push_back(b);
	}
	n = sz(x) - 1;
	if (n & 1) cout << 5 / 0;
	if (n <= 4) {
		sort(all(y));
		if ((y[n] - y[1]) & 1) cout << 0 << ' ';
		else cout << m - (m & 1);
		return;
	}
	for (int i = 1; i <= n; i++) {
		if (i > 1 && i < n && ((x[i - 1] == x[i] && x[i] == x[i + 1]) || (y[i - 1] == y[i] && y[i] == y[i + 1]))) continue;
		if ((y[i] & 1) || (x[i] & 1)) {
			cout << x[i] - (x[i] & 1);
			return;
		}
	}
	cout << m - (m & 1);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:33:23: warning: division by zero [-Wdiv-by-zero]
   33 |  if (n & 1) cout << 5 / 0;
      |                     ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Runtime error 1 ms 348 KB Execution killed with signal 8
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 14 ms 1240 KB Output is correct
3 Correct 14 ms 1420 KB Output is correct
4 Incorrect 19 ms 2248 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Runtime error 1 ms 348 KB Execution killed with signal 8
13 Halted 0 ms 0 KB -