QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396865#2616. Attack OrderKevin5307WA 1ms3640kbC++202.3kb2024-04-23 11:39:412024-04-23 11:39:41

Judging History

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

  • [2024-04-23 11:39:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-04-23 11:39:41]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		if(n==k)
			cout<<"-1\n";
		else if(!k)
		{
			if(n==3)
			{
				cout<<3<<endl;
				cout<<"1 2"<<endl;
				cout<<"2 3"<<endl;
				cout<<"3 1"<<endl;
			}
			else if(n==4)
			{
				cout<<4<<endl;
				cout<<"1 2"<<endl;
				cout<<"2 3"<<endl;
				cout<<"3 4"<<endl;
				cout<<"4 1"<<endl;
			}
			else if(5+(n-5)*2<=n-1+n/2)
			{
				cout<<5+(n-5)*2<<endl;
				for(int i=1;i<=5;i++)
					cout<<i<<" "<<i%5+1<<endl;
				for(int i=6;i<=n;i++)
				{
					cout<<2<<" "<<i<<endl;
					cout<<5<<" "<<i<<endl;
				}
			}
			else if(n%2)
			{
				cout<<(n-1)/2*3<<endl;
				for(int i=2;i<=n;i++)
					cout<<1<<" "<<i<<endl;
				for(int i=2;i<=n;i+=2)
					cout<<i<<" "<<i+1<<endl;
			}
			else
			{
				cout<<(n-1)+n/2<<endl;
				for(int i=2;i<=n;i++)
					cout<<1<<" "<<i<<endl;
				for(int i=2;i<n;i+=2)
					cout<<i<<" "<<i+1<<endl;
				cout<<2<<" "<<n<<endl;
			}
		}
		else
		{
			if((n-k)%2)
			{
				cout<<k+(n-k-1)/2*3<<endl;
				for(int i=1;i<=k;i++)
					cout<<i<<" "<<k+1<<endl;
				for(int i=k+2;i<=n;i++)
					cout<<k+1<<" "<<i<<endl;
				for(int i=k+2;i<=n;i+=2)
					cout<<i<<" "<<i+1<<endl;
			}
			else if(k==n-2)
				cout<<"-1\n";
			else
			{
				cout<<k+(n-k-1)+(n-k)/2<<endl;
				for(int i=1;i<=k;i++)
					cout<<i<<" "<<k+1<<endl;
				for(int i=k+2;i<=n;i++)
					cout<<k+1<<" "<<i<<endl;
				for(int i=k+2;i<n;i+=2)
					cout<<i<<" "<<i+1<<endl;
				cout<<k+2<<" "<<n<<endl;
			}
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3640kb

input:

3
2
15 25
10 5
3
7 0
7 3
10 0
3
10 10
20 20
30 30

output:

-6
1 16
2 16
3 16
4 16
5 16
6 16
7 16
8 16
9 16
10 16
11 16
12 16
13 16
14 16
15 16
31
1 11
2 11
3 11
4 11
5 11
6 11
7 11
8 11
9 11
10 11
11 12
11 13
11 14
11 15
11 16
11 17
11 18
11 19
11 20
11 21
11 22
11 23
11 24
11 25
12 13
14 15
16 17
18 19
20 21
22 23
24 25
-1

result:

wrong output format YES or NO expected, but -6 found [1st token]