QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238552#7688. Alea Iacta Estucup-team191#WA 10ms32732kbC++141.3kb2023-11-04 17:00:452023-11-04 17:00:46

Judging History

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

  • [2023-11-04 17:00:46]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:32732kb
  • [2023-11-04 17:00:45]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

const int N = 3e6 + 500;

int tmp[N], odg[N], cnt[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(ll i = 1;i * i <= fak;i++) {
		if(fak % i == 0 && i != m) f1 = i;
	}
	f2 = fak / f1;
	int pos = 0;
	if(f1 == -1 || f1 + f2 > n + 2 * m) {
		f1 = m, f2 = n, pos = 1;
	}
	for(int i = 2;i <= n + m;i++)
		cnt[i] = min(i - 1, n) - max(i - m, 1) + 1;
	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;
	for(;T--;) {
		//printf("T = %d\n", T);
		solve();
	}
	//cout << in << endl;
	//cout << out << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5680kb

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: 3ms
memory: 8236kb

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: 6056kb

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: 0ms
memory: 5980kb

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: 5936kb

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: 0ms
memory: 8032kb

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: -100
Wrong Answer
time: 10ms
memory: 32732kb

input:

1
999983 999983

output:

1 1 
-761379679 

result:

wrong answer Integer parameter [name=m1] equals to -761379679, violates the range [1, 2999949] (test case 1)