QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391440#6432. Puzzle in InazumaDYSisNoobWA 0ms3524kbC++142.4kb2024-04-16 16:27:512024-04-16 16:27:52

Judging History

This is the latest submission verdict.

  • [2024-04-16 16:27:52]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3524kb
  • [2024-04-16 16:27:51]
  • Submitted

answer

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, sum = 0;
	cin >> n;
	vector<vector<int>> num(n + 1, vector<int>(n + 1)), ans;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			cin >> num[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			int tmp;
			cin >> tmp;
			num[i][j] -= tmp;
			sum += num[i][j];
		}
	}
	if (sum != 0)
	{
		cout << -1 << '\n';
		return 0;
	}
	if (n > 5)
	{
		auto ins = [&](int a, int b, int c, int d, int x) -> void
		{
			ans.push_back(vector<int>(5));
			ans.end()[-1][0] = a, ans.end()[-1][1] = b, ans.end()[-1][2] = c, ans.end()[-1][3] = d, ans.end()[-1][4] = x;
		};
		for (int i = 2; i <= n; i++)
		{
			for (int j = i + 1; j <= n; j++)
			{
				if (num[i][j] == 0)  continue;
				int tmp[7] = {i, 0, 0, j, 0, 1, num[i][j]};
				for (int k = 2, cur = 1; k <= 6; k++)
				{
					if (cur > 4)  break;
					if (k != i && k != j)  tmp[cur] = k, cur <<= 1;
				}
				ins(tmp[3], tmp[0], tmp[1], tmp[4], -tmp[6]);
				ins(tmp[3], tmp[0], tmp[1], tmp[2], tmp[6]);
				ins(tmp[4], tmp[0], tmp[2], tmp[3], tmp[6]);
				ins(tmp[4], tmp[0], tmp[1], tmp[2], -tmp[6]);
				ins(tmp[5], tmp[0], tmp[1], tmp[4], tmp[6]);
				ins(tmp[5], tmp[0], tmp[1], tmp[2], -tmp[6]);
				ins(tmp[4], tmp[0], tmp[2], tmp[5], -tmp[6]);
				ins(tmp[4], tmp[0], tmp[1], tmp[2], tmp[6]);
				num[1][i] += num[i][j];
				num[i][j] = 0;
			}
		}
		for (int i = 3; i <= n; i++)
		{
			if (num[1][i] == 0)  continue;
			int tmp[7] = {1, 0, 0, i, 0, 2, num[1][i]};
			for (int j = 3, cur = 1; j <= 6; j++)
			{
				if (cur > 4)  break;
				if (j != i)  tmp[cur] = j, cur <<= 1;
			}
			ins(tmp[3], tmp[0], tmp[1], tmp[4], -tmp[6]);
			ins(tmp[3], tmp[0], tmp[1], tmp[2], tmp[6]);
			ins(tmp[4], tmp[0], tmp[2], tmp[3], tmp[6]);
			ins(tmp[4], tmp[0], tmp[1], tmp[2], -tmp[6]);
			ins(tmp[5], tmp[0], tmp[1], tmp[4], tmp[6]);
			ins(tmp[5], tmp[0], tmp[1], tmp[2], -tmp[6]);
			ins(tmp[4], tmp[0], tmp[2], tmp[5], -tmp[6]);
			ins(tmp[4], tmp[0], tmp[1], tmp[2], tmp[6]);
			num[1][2] += num[1][i];
			num[1][i] = 0;
		}
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			for (int j = 0; j <= 4; j++)
			{
				cout << ans[i][j] << " ";
			}
			cout << '\n';
		}
	}
	else if (n == 5)
	{
		
	}
	else
	{
		
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3524kb

input:

4
0 1 1
0 0
1
1 0 0
1 1
0

output:


result:

wrong output format Unexpected end of file - int32 expected