QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201376#5154. ETAnameless_story#WA 0ms3812kbC++201.1kb2023-10-05 14:01:102023-10-05 14:01:11

Judging History

This is the latest submission verdict.

  • [2023-10-05 14:01:11]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3812kb
  • [2023-10-05 14:01:10]
  • Submitted

answer

#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T1,class T2> bool cmin(T1 &x,const T2 &y) { if (y<x) { x=y; return 1; }return 0; }
template<class T1,class T2> bool cmax(T1 &x,const T2 &y) { if (x<y) { x=y; return 1; }return 0; }
#define all(x) (x).begin(),(x).end()
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cout<<fixed<<setprecision(15);
	ll n,m; char xxx;
	cin>>n>>xxx>>m;
	if (n<m-1)
	{
		cout<<"impossible\n";
		return 0;
	}
	if (n==m-1)
	{
		cout<<m<<' '<<m-1<<'\n';
		for (int i=2; i<=m; i++)
			cout<<1<<' '<<i<<'\n';
		return 0;
	}
	ll d=10/m;
	m=m*d;
	n=n*d;
	vector a(1,m-1);
	if (n<m-1||n>m*(m-1)/2)
	{
		cout<<"impossible\n";
		return 0;
	}
	ll sum=m-1;
	if (sum<n)
		for (int i=2; i<=m; i++)
		{
			if (sum+m-i<=n)
				sum+=m-i,a.push_back(m-i);
			else
			{
				a.push_back(n-sum);
				sum=n;
				break;
			}
		}
	a.push_back(0);
	int cnt=1,pre=1;
	cout<<m<<' '<<m-1<<'\n';
	for (int i=0; i<a.size()-1; i++)
	{
		ll tp;
		for (int j=1; j<=a[i]-a[i+1]; j++)
		{
			cout<<pre<<' '<<cnt+j<<'\n';
			tp=cnt+j;
		}
		pre=tp;
		cnt+=a[i]-a[i+1];
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

1/3

output:

impossible

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

7/4

output:

8 7
1 2
2 3
2 4
2 5
2 6
2 7
7 8

result:

ok 

Test #4:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

974/975

output:

975 974
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
...

result:

ok 

Test #5:

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

input:

943/346

output:

0 -1

result:

wrong answer Integer parameter [name=n] equals to 0, violates the range [1, 1000000]