QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195228 | #5154. ETA | kevinshan# | WA | 0ms | 3816kb | C++14 | 1.8kb | 2023-10-01 02:26:18 | 2023-10-01 02:26:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ps push
#define in insert
#define f first
#define s second
#define nl cout<<"\n"
#define ca(v) for(auto i:v) cout<<i<<" ";
#define cbit(x) __builtin_popcount(x)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a*b/gcd(a, b))
int xm[4] = {-1, 1, 0, 0};
int ym[4] = {0, 0, -1, 1};
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;
const ll POW = 9973;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
string s;cin>>s;
string A,B;
bool flag = false;
for(int i=0;i<s.size();i++) {
if (s[i]=='/') {
flag = true;
continue;
}
if (flag) {
B+=s[i];
} else A+=s[i];
}
int a = stoi(A);
int b = stoi(B);
for (int i=1;i<=2000;i++) {
// n nodes
int mn = i-1;
int mx = (i-1)*i/2;
if (i%b ==0) {
int sum = i/b*a;
if (sum>=mn && sum<=mx) {
int cur = mx-sum;
int n = i;
vector<int> ans(n);
for (int j=1;j<n;j++) {
ans[j] = j-1;
}
for (int j=n-1;j>=0;j--) {
int cando = j-1;
ans[j] = max(0, j-cur-1);
cur -= cando;
if (cur<=0) {
break;
}
}
cout << i << " " << i-1 << '\n';
for (int j=1;j<i;j++) {
cout << ans[j]+1 << " " << j+1 << '\n';
}
return 0;
}
}
}
cout << "impossible" << endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
1/2
output:
2 1 1 2
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1/3
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
7/4
output:
8 7 1 2 2 3 3 4 4 5 2 6 1 7 1 8
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3612kb
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: 0ms
memory: 3484kb
input:
943/346
output:
346 345 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 4 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...
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3608kb
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: 0ms
memory: 3780kb
input:
1/1
output:
3 2 1 2 2 3
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1/1000
output:
impossible
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1000/999
output:
999 998 1 2 2 3 2 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: 0ms
memory: 3628kb
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: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
1000/1
output:
impossible
result:
wrong output format Expected integer, but "impossible" found