Submission #683817

# Submission time Handle Problem Language Result Execution time Memory
683817 2023-01-19T11:59:39 Z luka1234 Nice sequence (IZhO18_sequence) C++14
15 / 100
11 ms 684 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define db double
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		if(n==2&&m==3){
			cout<<3<<"\n";
			cout<<"3 -4 2";
			cout<<"\n";
			continue;
		}
		if(n%m==0||m%n==0){
			if(n>=m){
				cout<<n-1<<"\n";
				for(int k=1;k<n;k++)
				    cout<<1<<' ';
				cout<<"\n";
			}
			else{
				cout<<m-1<<"\n";
				for(int k=1;k<m;k++)
				    cout<<-1<<' ';
				cout<<"\n";
			}
			continue;
	    }
	    if(min(n,m)==2){
	    	int ans[max(m,n)+1];
	    	if(n==2){
	    		cout<<m<<"\n";
	    		for(int k=1;k<=m;k+=2)
	    		    ans[k]=m-1;
	    		for(int k=2;k<=m;k+=2)
	    		    ans[k]=-m;
			}
			else{
				cout<<n<<"\n";
				for(int k=1;k<=n;k+=2)
	    		    ans[k]=-n+1;
	    		for(int k=2;k<=n;k+=2)
	    		    ans[k]=n;
			}
			for(int k=1;k<=max(m,n);k++)
			    cout<<ans[k]<<' ';
			cout<<"\n";
		}
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 296 KB Ok
6 Correct 1 ms 304 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 300 KB Ok
11 Correct 1 ms 296 KB Ok
12 Correct 1 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 1 ms 224 KB Ok
5 Correct 1 ms 300 KB Ok
6 Correct 2 ms 340 KB Ok
7 Correct 8 ms 684 KB Ok
8 Correct 4 ms 468 KB Ok
9 Correct 11 ms 680 KB Ok
10 Correct 5 ms 468 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 1 ms 296 KB Ok
3 Correct 1 ms 212 KB Ok
4 Incorrect 1 ms 300 KB Jury has the better answer : jans = 9, pans = 2
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 296 KB Ok
6 Correct 1 ms 304 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 300 KB Ok
11 Correct 1 ms 296 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 1 ms 212 KB Ok
14 Correct 1 ms 296 KB Ok
15 Correct 1 ms 212 KB Ok
16 Incorrect 1 ms 300 KB Jury has the better answer : jans = 9, pans = 2
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 296 KB Ok
6 Correct 1 ms 304 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 300 KB Ok
11 Correct 1 ms 296 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 212 KB Ok
14 Correct 1 ms 212 KB Ok
15 Correct 1 ms 212 KB Ok
16 Correct 1 ms 224 KB Ok
17 Correct 1 ms 300 KB Ok
18 Correct 2 ms 340 KB Ok
19 Correct 8 ms 684 KB Ok
20 Correct 4 ms 468 KB Ok
21 Correct 11 ms 680 KB Ok
22 Correct 5 ms 468 KB Ok
23 Correct 1 ms 212 KB Ok
24 Correct 1 ms 296 KB Ok
25 Correct 1 ms 212 KB Ok
26 Incorrect 1 ms 300 KB Jury has the better answer : jans = 9, pans = 2
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 296 KB Ok
6 Correct 1 ms 304 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 300 KB Ok
11 Correct 1 ms 296 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 212 KB Ok
14 Correct 1 ms 212 KB Ok
15 Correct 1 ms 212 KB Ok
16 Correct 1 ms 224 KB Ok
17 Correct 1 ms 300 KB Ok
18 Correct 2 ms 340 KB Ok
19 Correct 8 ms 684 KB Ok
20 Correct 4 ms 468 KB Ok
21 Correct 11 ms 680 KB Ok
22 Correct 5 ms 468 KB Ok
23 Correct 1 ms 212 KB Ok
24 Correct 1 ms 296 KB Ok
25 Correct 1 ms 212 KB Ok
26 Incorrect 1 ms 300 KB Jury has the better answer : jans = 9, pans = 2
27 Halted 0 ms 0 KB -