QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#328213#8034. Ban or Pick, What's the TrickPetroTarnavskyi#WA 1ms3704kbC++201.8kb2024-02-15 18:19:362024-02-15 18:19:37

Judging History

This is the latest submission verdict.

  • [2024-02-15 18:19:37]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3704kb
  • [2024-02-15 18:19:36]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;


vector<vector<PII>> res;
int solve(vector<PII> v, int t)
{
	int cnt = 0;
	while (cnt < 300 && !v.empty())
	{
		
		if(t == 1)
			res.PB(v);	
			
		set<PII> cand;
		FOR (i, 0, SZ(v))
		{
			FOR (dx, -1, 2)
			{
				FOR (dy, -1, 2)
					cand.insert({v[i].F + dx, v[i].S + dy});
			}
		}
		vector<PII> nv;
		for (auto p : cand)
		{
			int susids = 0;
			bool alive = false;
			FOR (i, 0, SZ(v))
			{
				if (p == v[i])
				{
					alive = 1;
					continue;
				}
				int dx = abs(p.F - v[i].F);
				int dy = abs(p.S - v[i].S);
				int mx = max(dx, dy);
				int d = dx + dy;
				if (mx < 2 && d <= 2)
					susids++;
			}
			if (susids == 3 || (susids == 2 && alive))
				nv.PB(p);
		}
		v = nv;
		cnt++;	
			
	}
	return cnt;
}

vector<PII> solution(int k)
{
	if(k <= 31)
	{
		return res[SZ(res) - k];
	}
	k -= 31;
	
	int cnt = k / 4;
	
	if(k % 4 == 0)
	{
		vector<PII> cur = {MP(0 - cnt, 2 - cnt), MP(1 - cnt, 0 - cnt), MP(1 - cnt, 2 - cnt), MP(2 - cnt, 1 - cnt), MP(2 - cnt, 2 - cnt),		
		MP(5, 3), MP(5, 4), MP(6, 3), MP(6, 4)};
		return cur;
	}
	
}



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	vector<PII> cur = {MP(0, 2), MP(1, 0), MP(1, 2), MP(2, 1), MP(2, 2),
	MP(5, 3), MP(5, 4), MP(6, 3), MP(6, 4)};
	
	solve(cur, 1);
	
	int k;
	cin >> k;
	vector<PII> ans = solution(k);
	
	cout << solve(ans, 0) << endl;
	assert(solve(ans, 0) == k);
		
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3704kb

input:

2 1
3 6
2 4

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3628kb

input:

4 1
1 3 5 7
2 4 6 8

output:

4

result:

wrong answer 1st lines differ - expected: '0', found: '4'