QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501523#5154. ETATimeless123RE 0ms3636kbC++171.2kb2024-08-02 20:01:312024-08-02 20:01:31

Judging History

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

  • [2024-08-02 20:01:31]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3636kb
  • [2024-08-02 20:01:31]
  • 提交

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;
}

详细

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

output:


result: