QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662443 | #5154. ETA | zmrzmr | WA | 0ms | 3672kb | C++14 | 2.0kb | 2024-10-21 00:22:01 | 2024-10-21 00:22:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll _int128
#define ull unsigned long long
#define PB push_back
#define fi first
#define se second
#define _int _int128
#define fr(i,a,b) for(int i = a ; i <= b ; i++)
#define rp(i,a,b) for(int i = a ; i >= b ; i--)
#define frp(i,a,b) for(int i = 1 ; i < b ; i ++ )
#define re read()
#define db double
#define ld long double
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int inf = 0x3f3f3f3f;
const ll N = 2e5+10;
const ll mod = 1e9+7;
inline ll read()
{
ll x=0,f=0;
char ch=getchar();
while (!isdigit(ch))
f|=(ch =='-'),ch = getchar();
while (isdigit(ch))
x=(x<<1)+(x<<3)+(ch^= 48),ch = getchar();
return f?-x:x;
}
inline void write(ll x)
{
if(x < 0)
putchar('-'),x=-x;
if(x > 9)
write(x/10);
putchar(x%10 + 48);
}
inline void W(ll x,char ch)
{
write(x);
putchar(ch);
}
ll aa[N];
void slove()
{
ll a,b;
char c;
cin>>a>>c>>b;
if(a < b)
{
if(a == b - 1)
{
cout<<b<<" "<<a<<endl;
fr(i,2,b)
{
cout<<1<<" "<<i<<endl;
}
return;
}
cout<<"impossible"<<endl;
return;
}
ll k = a/b;
ll s = 0;
fr(i,0,2*k)
{
if(i == k )
{
if(b == 1)
{
aa[i] = 4*k;
s += (4*k)*i;
}
else
{
aa[i] = 2*k*(b-1) + k*b; s += (4*k*b-2*k)*i;
}
continue;
}
s += i;
aa[i] = 1;
}
ll sum;
if(b == 1)
{
sum = 6*k;
}
else sum = 3*k*b; //总点
ll tt = a*(sum/b);
ll cha = s - a*(sum/b);
cha = abs(cha);
// cout<<cha<<" "<<s<<tt<<endl;
aa[k] -= cha;
aa[k+1]+=cha;
ll cn;
cout<<sum<<" "<<sum-1<<endl;
fr(i,1,2*k)
{
cout<<i<<" "<<i+1<<endl;
cn = i + 2;
}
fr(i,1,aa[k] - 1)
{
cout<<k<<" "<<cn++<<endl;
}
fr(i,1,aa[k+1]-1)
{
cout<<k+1<<" "<<cn++<<endl;
}
}
int main()
{
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int tcase = 1;
// cin>>tcase;
while(tcase--)
{
slove();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
1/2
output:
2 1 1 2
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1/3
output:
impossible
result:
ok
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
input:
7/4
output:
12 11 1 2 2 3 1 4 1 5 1 6 1 7 2 8 2 9 2 10 2 11 2 12
result:
FAIL Wrong average distance, got 17/12, wanted 7/4