Submission #342720

# Submission time Handle Problem Language Result Execution time Memory
342720 2021-01-02T16:41:37 Z David_M Nice sequence (IZhO18_sequence) C++14
6 / 100
19 ms 23916 KB
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define S second
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=200006, INF=1e18;
     
ll pos, l, r, n, m, t, a[N], b[N], h[N], p[20][N], q, k, x, y;
vector <ll> v[N];
set <ll> s[N], S[N];

int main(){ios_base::sync_with_stdio(false), cin.tie(0);
	cin>>q;
	while(q--){
		cin>>n>>m;
	
		if (n>m){
			if(n%m==0){
				cout<<n-1<<'\n';
				for (int i=1; i<n; i++)cout<<"1 ";
				cout<<'\n';
				continue;
			}
			if(m==2){
				cout<<n<<"\n-1 ";
				for (int i=1; i<n; i+=2)cout<<"1 -1 ";
				cout<<'\n';
			}
		}else{
			if(m%n==0){
				cout<<m-1<<'\n';
				for (int i=1; i<m; i++)cout<<"-1 ";
				cout<<'\n';
				continue;
			}
			if(n==2){
				cout<<m<<"\n1 ";
				for (int i=1; i<m; i+=2)cout<<"-1 1 ";
				cout<<'\n';
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Ok
2 Correct 16 ms 23788 KB Ok
3 Correct 16 ms 23788 KB Ok
4 Correct 16 ms 23788 KB Ok
5 Correct 16 ms 23788 KB Ok
6 Correct 16 ms 23768 KB Ok
7 Correct 16 ms 23788 KB Ok
8 Correct 17 ms 23788 KB Ok
9 Correct 16 ms 23788 KB Ok
10 Correct 16 ms 23788 KB Ok
11 Correct 16 ms 23788 KB Ok
12 Correct 16 ms 23788 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 23916 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 23808 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 23916 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Ok
2 Correct 16 ms 23788 KB Ok
3 Correct 16 ms 23788 KB Ok
4 Correct 16 ms 23788 KB Ok
5 Correct 16 ms 23788 KB Ok
6 Correct 16 ms 23768 KB Ok
7 Correct 16 ms 23788 KB Ok
8 Correct 17 ms 23788 KB Ok
9 Correct 16 ms 23788 KB Ok
10 Correct 16 ms 23788 KB Ok
11 Correct 16 ms 23788 KB Ok
12 Correct 16 ms 23788 KB Ok
13 Incorrect 16 ms 23808 KB there is incorrect sequence
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Ok
2 Correct 16 ms 23788 KB Ok
3 Correct 16 ms 23788 KB Ok
4 Correct 16 ms 23788 KB Ok
5 Correct 16 ms 23788 KB Ok
6 Correct 16 ms 23768 KB Ok
7 Correct 16 ms 23788 KB Ok
8 Correct 17 ms 23788 KB Ok
9 Correct 16 ms 23788 KB Ok
10 Correct 16 ms 23788 KB Ok
11 Correct 16 ms 23788 KB Ok
12 Correct 16 ms 23788 KB Ok
13 Incorrect 17 ms 23916 KB there is incorrect sequence
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Ok
2 Correct 16 ms 23788 KB Ok
3 Correct 16 ms 23788 KB Ok
4 Correct 16 ms 23788 KB Ok
5 Correct 16 ms 23788 KB Ok
6 Correct 16 ms 23768 KB Ok
7 Correct 16 ms 23788 KB Ok
8 Correct 17 ms 23788 KB Ok
9 Correct 16 ms 23788 KB Ok
10 Correct 16 ms 23788 KB Ok
11 Correct 16 ms 23788 KB Ok
12 Correct 16 ms 23788 KB Ok
13 Incorrect 17 ms 23916 KB there is incorrect sequence
14 Halted 0 ms 0 KB -