QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116918#6667. Prosjekyoungsystem#0 44ms8224kbC++201.9kb2023-06-30 10:48:342024-05-31 18:34:28

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 18:34:28]
  • 评测
  • 测评结果:0
  • 用时:44ms
  • 内存:8224kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 10:48:34]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int nx[105],ny[105],tmp;
bool dfs(vector<int> v)
{
	if(v.size()==1)
	{
		for(int i=1;i<=tmp;i++)printf("%lld %lld\n",nx[i],ny[i]);
		return true;
	}
	for(int i=0;i<v.size();i++)
	{
		for(int j=i+1;j<v.size();j++)
		{
			if((v[i]+v[j])%2!=0)continue;
			vector<int>nv;
			for(int k=0;k<v.size();k++)
			{
				if(k!=i&&k!=j)nv.push_back(v[k]);
			}
			nx[++tmp]=v[i];
			ny[tmp]=v[j];
			nv.push_back((v[i]+v[j])/2);
			if(dfs(nv)==true)
			{
				return true;
			}
			tmp--;
		}
	}
	return false;
}
int a[1000005];
int sta1[1000005],top1;
int sta2[1000005],top2;
signed main()
{
	int t,n;
	t=read();
	for(int greg=1;greg<=t;greg++)
	{
		n=read();
		for(int i=1;i<=n;i++)
		{
			a[i]=read();
		}
		if(n<=7)
		{
			vector<int>v;
			for(int i=1;i<=n;i++)v.push_back(a[i]);
			if(dfs(v)==false)printf("-1\n");
			continue;
		}
		bool flag=true;
		for(int i=1;i<=n;i++)
		{
			if(a[i]%2!=0)
			{
				flag=false;
				break;
			}
		}
		if(flag==true)
		{
			top1=top2=0;
			for(int i=1;i<=n;i++)
			{
				if(a[i]%4==0)sta1[++top1]=a[i];
				else sta2[++top2]=a[i];
			}
			for(int i=1;i<=n-2;i++)
			{
				if(top1>=2)
				{
					printf("%lld %lld\n",sta1[top1],sta1[top1-1]);
					int sth=(sta1[top1]+sta1[top1-1])/2;
					top1-=2;
					sta1[++top1]=sth;
				}
				else
				{
					printf("%lld %lld\n",sta2[top2],sta2[top2-1]);
					int sth=(sta2[top2]+sta2[top2-1])/2;
					top2-=2;
					sta2[++top2]=sth;
				}
			}
			if(top1==2)printf("%lld %lld\n",sta1[1],sta1[2]);
			else if(top2==2)printf("%lld %lld\n",sta2[1],sta2[2]);
			else printf("%lld %lld\n",sta1[1],sta2[1]);
		}
	}
	return 0;
}

详细

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

99
4
739880851158065302 19206582949872932 883064254701115295 222072661880779376
7
148399819461615003 209088712310207988 53191076581680214 445068618251612752 230505279594622109 115754892157516718 804173775829453588
2
77979357045500669 41693388829622019
3
341612949433488278 609808714829036935 19994167...

output:

739880851158065302 19206582949872932
883064254701115295 379543717053969117
222072661880779376 631303985877542206
739880851158065302 19206582949872932
883064254701115295 379543717053969117
222072661880779376 631303985877542206
148399819461615003 230505279594622109
209088712310207988 53191076581680214...

result:


Subtask #2:

score: 0
Runtime Error

Test #16:

score: 0
Runtime Error

input:

100
3
3 3 2
3
4 1 1
4
1 3 4 4
6
4 4 2 3 1 2
4
0 2 1 4
3
0 2 0
7
3 3 1 1 3 4 0
2
0 4
4
1 4 2 3
7
4 0 0 3 2 3 4
4
4 2 0 3
7
0 2 2 1 4 2 4
7
3 0 3 1 2 0 3
4
4 3 1 4
6
2 3 0 1 3 4
5
1 4 0 3 4
5
4 2 0 4 2
3
0 1 2
6
4 1 4 2 0 4
7
4 2 4 3 1 3 1
4
1 4 4 0
2
1 1
6
0 3 3 0 0 4
7
4 3 0 3 3 3 4
4
4 1 1 3
6
2 0 ...

output:

-1
-1
1 3
4 4
2 4
1 3
4 4
2 4
4 4
2 2
3 1
2 2
4 2
1 3
4 4
2 4
4 4
2 2
3 1
2 2
4 2
2 4
1 3
0 2
1 3
4 4
2 4
4 4
2 2
3 1
2 2
4 2
2 4
1 3
0 2
0 0
2 0
1 3
4 4
2 4
4 4
2 2
3 1
2 2
4 2
2 4
1 3
0 2
0 0
2 0
3 3
1 1
3 3
4 0
1 3
2 2
1 3
4 4
2 4
4 4
2 2
3 1
2 2
4 2
2 4
1 3
0 2
0 0
2 0
3 3
1 1
3 3
4 0
1 3
2 2
0 ...

result:


Subtask #3:

score: 0
Runtime Error

Test #34:

score: 0
Runtime Error

input:

100000
5
846784256447769304 457696478728961702 128469521648960690 597630796847754190 104256763714529164
5
658897822238868978 472135077337628566 399538027669313322 622703684108675696 425723088635325654
5
917704960887390986 140817562615382054 877934664521057998 782212806618666818 616380973421914538
8
...

output:

846784256447769304 457696478728961702
597630796847754190 104256763714529164
652240367588365503 350943780281141677
128469521648960690 501592073934753590
846784256447769304 457696478728961702
597630796847754190 104256763714529164
652240367588365503 350943780281141677
128469521648960690 501592073934753...

result:


Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 44ms
memory: 8224kb

input:

100
211957
911918942087402387 344230223346742784 16289402153237664 528890583619159010 886281719684850237 865484734102017297 321851390502278959 754268375474197153 237414161302130571 135637002716682378 824412491959977735 162505521049217610 246319278060116103 666703181591704279 650875500699154233 96397...

output:

945205410564117397 506489830890255987
705650240624406006 441192426604140330
186919616587700128 605645018889792892
725847620727186692 396282317738746510
298912059620894683 561064969232966601
573421333614273168 429988514426930642
945205410564117397 506489830890255987
705650240624406006 441192426604140...

result:

wrong answer Integer -1 violates the range [0, 10^18] (test case 1)