QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#876541#7696. Forest for the TreesWeaRD276WA 1ms3584kbC++202.8kb2025-01-30 23:39:122025-01-30 23:39:13

Judging History

This is the latest submission verdict.

  • [2025-01-30 23:39:13]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3584kb
  • [2025-01-30 23:39:12]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#include  <ext/pb_ds/assoc_container.hpp>
#include  <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#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--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;

int solve()
{
	int n, m, r;
	if (!(cin >> n >> m >> r))
		return 1;
	
	assert(n >= m);
	set<pii> tr;
	vector<pii> de(m);
	FOR (i, 0, n)
	{
		int x, y;
		cin >> x >> y;
		tr.insert({x, y});
	}
		
	FOR (i, 0, m)
		cin >> de[i].x >> de[i].y;
	
	auto check = [&](pii pos, int d) -> bool
	{
		bool ok = 1;
		FOR (i, 0, m)
		{
			pii cur;
			// up
			if (d == 0)
			{
				cur.x = pos.x + de[i].x;
				cur.y = pos.y + de[i].y;
			}
			// down
			if (d == 1)
			{
				cur.x = pos.x - de[i].x;
				cur.y = pos.y - de[i].y;
			}
			if (d == 2)
			{
				cur.x = pos.x + de[i].y;
				cur.y = pos.y - de[i].x;
			}
			// down
			if (d == 3)
			{
				cur.x = pos.x - de[i].y;
				cur.y = pos.y + de[i].x;
			}
			//cerr << cur.x << ' ' << cur.y << '\n';
			ok &= tr.count(cur);
		}
		//cerr << "==================================\n";
		return ok;
	};
	
	//1 1
	//2 2
	//2 1
	//3 3
	
	set<pii> poses;
	for (pii tree: tr)
	{
		int x = tree.x, y = tree.y;
		FOR(d, 0, 4)
		{
			pii cur;
			if (d == 0)
			{
				cur.x = x + de[0].x;
				cur.y = y + de[0].y;
			}
			// down
			if (d == 1)
			{
				cur.x = x - de[0].x;
				cur.y = y - de[0].y;
			}
			if (d == 2)
			{
				cur.x = x + de[0].y;
				cur.y = y - de[0].x;
			}
			// down
			if (d == 3)
			{
				cur.x = x - de[0].y;
				cur.y = y + de[0].x;
			}
			//cerr << cur.x << ' ' << cur.y << '\n';
			FOR (j, 0, 4)
				if (check(cur, j))
					poses.insert(cur);
		}
	}
	//FOR (i, 0, 4)
		//cout << check({0, 1}, i) << '\n';
	if (sz(poses) == 1)
		cout << poses.begin()->x << ' ' << poses.begin()->y << '\n';
	else if (poses.empty())
		cout << "Impossible\n";
	else
		cout << "Ambiguous\n";
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

詳細信息

Test #1:

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

input:

4 4 100
1 1
2 2
2 1
3 3
0 1
0 2
-1 2
-2 3

output:

0 1

result:

ok single line: '0 1'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

4 4 4
0 1
1 0
0 -1
-1 0
0 1
1 0
0 -1
-1 0

output:

0 0

result:

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