QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501523 | #5154. ETA | Timeless123 | RE | 0ms | 3636kb | C++17 | 1.2kb | 2024-08-02 20:01:31 | 2024-08-02 20:01:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 205+9;
const int mod = 1e9+7;
#define inf 8e10
int dep[N];
vector<int> g[N];
void solve()
{
ll a,b;char c;cin>>a>>c>>b;
if(a*1.0/b < 0.5)
{
cout<<"impossible"<<'\n';
return ;
}
ll x=a,y=b;
while(1)
{
if(y * (y - 1) / 2 >= x) break;
x += a,y += b;
}
cout<< y <<' ' << y - 1<<'\n';
int pos=2,sum=0;
dep[1]=0;
for(int i=2;i<=y;++i) dep[i]=1,sum+=1;
while(1)
{
if(sum==x) break;
int i;
for(i=y;i>pos;--i)
{
dep[i]++;
if(++sum == x) break;
}
if(i==pos) pos++;
if(sum==x) break;
}
// for(int i=1;i<=y;++i) cout<<dep[i]<<' ';
int now=1;
for(int i=2;i<=y;++i)
{
if(dep[i]==dep[now] + 1) g[now].push_back(i);
else
{
now = i - 1;
i--;
}
}
for(int i=1;i<=y;++i)
{
for(auto &y:g[i])
cout<<i<<' '<<y<<'\n';
}
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1; // cin>>_;
while (_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
1/2
output:
2 1 1 2
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1/3
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3636kb
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: -100
Runtime Error
input:
974/975