QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501531 | #5154. ETA | Timeless123 | TL | 7ms | 29024kb | C++17 | 1.3kb | 2024-08-02 20:11:30 | 2024-08-02 20:11:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 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 && (y - 1) <= x) break;
x += a,y += b;
}
int pos=2,sum=0;
dep[1]=0;
for(int i=2;i<=y;++i) dep[i]=1,sum+=1;
if(sum>x)
{
cout<<"impossible"<<'\n';
return ;
}
cout<< y <<' ' << y - 1<<'\n';
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: 27716kb
input:
1/2
output:
2 1 1 2
result:
ok
Test #2:
score: 0
Accepted
time: 3ms
memory: 27464kb
input:
1/3
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 3ms
memory: 29024kb
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: 27780kb
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: 0
Accepted
time: 7ms
memory: 27500kb
input:
943/346
output:
346 345 1 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 ...
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 28984kb
input:
912/7
output:
266 265 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 ...
result:
ok
Test #7:
score: 0
Accepted
time: 3ms
memory: 28236kb
input:
1/1
output:
3 2 1 2 2 3
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 28884kb
input:
1/1000
output:
impossible
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 28664kb
input:
1000/999
output:
999 998 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 #10:
score: 0
Accepted
time: 3ms
memory: 28628kb
input:
999/1000
output:
1000 999 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 #11:
score: 0
Accepted
time: 4ms
memory: 28868kb
input:
1000/1
output:
2001 2000 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 5...
result:
ok
Test #12:
score: 0
Accepted
time: 4ms
memory: 27676kb
input:
999/2
output:
1000 999 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52...
result:
ok
Test #13:
score: 0
Accepted
time: 4ms
memory: 28464kb
input:
1000/3
output:
669 668 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 ...
result:
ok
Test #14:
score: 0
Accepted
time: 7ms
memory: 28548kb
input:
26/3
output:
21 20 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 13 15 13 16 13 17 13 18 13 19 13 20 13 21
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 27604kb
input:
79/9
output:
27 26 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 21 22 21 23 21 24 21 25 21 26 21 27
result:
ok
Test #16:
score: 0
Accepted
time: 3ms
memory: 27328kb
input:
80/9
output:
27 26 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 11 13 11 14 11 15 11 16 11 17 11 18 18 19 18 20 18 21 18 22 18 23 18 24 18 25 18 26 18 27
result:
ok
Test #17:
score: 0
Accepted
time: 3ms
memory: 27636kb
input:
998/999
output:
999 998 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 #18:
score: -100
Time Limit Exceeded
input:
997/999