QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#239071 | #7688. Alea Iacta Est | ucup-team191# | WA | 129ms | 33028kb | C++14 | 1.8kb | 2023-11-04 18:20:55 | 2023-11-04 18:20:55 |
Judging History
answer
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 3e6 + 500;
int tmp[N], odg[N], cnt[N], svi[N], out = 0, in = 0;
void solve(){
int n, m; cin >> n >> m;
if(n < m) swap(n, m);
ll fak = (ll)n * m;
int f1 = -1, f2;
for(int i = 2;i <= n + m;i++)
cnt[i] = min(i - 1, n) - max(i - m, 1) + 1;
ll poc = sqrt(fak) + 1;
if(poc * poc > fak) poc--;
for(ll i = poc;i >= 1;i--) {
if(fak % i == 0 && i != m && i + fak / i < (ll)n + 2 * m) {
int sm = 0;
for(int j = 2;j <= n + m;j += i) {
sm += cnt[j];
}
if(sm == fak / i) {
for(int j = 0;j < i;j++) svi[j] = 0;
for(int j = 2;j <= n + m;j++)
svi[j % i] += cnt[j];
int dobar = 1;
for(int j = 0;j < i;j++)
dobar &= svi[j] == fak / i;
if(dobar) {
f1 = i;
break;
}
}
}
}
f2 = fak / f1;
int pos = 0;
if(f1 == -1 || f1 + f2 > n + 2 * m) {
f1 = m, f2 = n, pos = 1;
}
//cout << n << " " << m << "\n";
if(!pos) {
cout << f1 << ' ';
for(int i = 0;i < f1;i++) cout << i + 1 << ' ';
} else {
cout << 2 * f1 << ' ';
for(int i = 0;i < f1;i++) cout << i + 1 << ' ' << i + 1 << ' ';
}
cout << '\n' << f2 << ' ';
int cur = 0, sad = 1;
for(int i = 0;i < f2;i++) {
while(cur == cnt[sad]) {
sad++; cur -= tmp[sad];
}
cout << sad - 1 << ' ';
cur++; tmp[sad + f1]++;
}
cout << '\n';
for(int i = 0;i <= n + m + 100;i++) tmp[i] = 0, odg[i] = 0, cnt[i] = 0;
out += f1 + f2; in += n;
//cout << n << " " << m << " " << f1 << " " << f2 << endl;
//if(f1 + f2 >= n + m) cout << "kurcina\n";
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int T; cin >> T;
//cout << T << endl;
for(;T--;) {
//printf("T = %d\n", T);
solve();
}
//cout << in << endl;
//cout << out << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7720kb
input:
3 2 8 1 9 2 9
output:
4 1 2 3 4 4 1 2 5 6 3 1 2 3 3 1 4 7 3 1 2 3 6 1 2 4 5 7 8
result:
ok Correct. (3 test cases)
Test #2:
score: 0
Accepted
time: 7ms
memory: 9792kb
input:
1 40013 40013
output:
80026 1 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 Correct. (1 test case)
Test #3:
score: 0
Accepted
time: 3ms
memory: 7872kb
input:
1 40013 1
output:
2 1 1 40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...
result:
ok Correct. (1 test case)
Test #4:
score: 0
Accepted
time: 3ms
memory: 7944kb
input:
1 2 40013
output:
4 1 1 2 2 40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...
result:
ok Correct. (1 test case)
Test #5:
score: 0
Accepted
time: 0ms
memory: 7888kb
input:
1 3 40013
output:
6 1 1 2 2 3 3 40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
result:
ok Correct. (1 test case)
Test #6:
score: 0
Accepted
time: 3ms
memory: 9836kb
input:
1 4 40013
output:
8 1 1 2 2 3 3 4 4 40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95...
result:
ok Correct. (1 test case)
Test #7:
score: 0
Accepted
time: 129ms
memory: 32296kb
input:
1 999983 999983
output:
1999966 1 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 Correct. (1 test case)
Test #8:
score: 0
Accepted
time: 44ms
memory: 21264kb
input:
1 1 999983
output:
2 1 1 999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
result:
ok Correct. (1 test case)
Test #9:
score: 0
Accepted
time: 43ms
memory: 20680kb
input:
1 2 999983
output:
4 1 1 2 2 999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ...
result:
ok Correct. (1 test case)
Test #10:
score: 0
Accepted
time: 39ms
memory: 20244kb
input:
1 999983 3
output:
6 1 1 2 2 3 3 999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96...
result:
ok Correct. (1 test case)
Test #11:
score: 0
Accepted
time: 47ms
memory: 21240kb
input:
1 999983 4
output:
8 1 1 2 2 3 3 4 4 999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 9...
result:
ok Correct. (1 test case)
Test #12:
score: -100
Wrong Answer
time: 106ms
memory: 33028kb
input:
1 1000000 1000000
output:
500000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
result:
wrong answer Jury has a better answer. (test case 1)