暑期集训 提高1 左右构造机TLE 30pts

#include <bits/stdc++.h>
#define int long long
using namespace std ;
int n , m , a [1010] , b [1010] , s1 , s2 , fl , la , ra , q [1010] , t ;
void L () {
	q [1] = a [n] ;
	for (int i = 2 ; i <= n ; i ++)
		q [i] = a [i - 1] ;
	for (int i = 1 ; i <= n ; i ++)  a [i] = q [i] ;
}
void R () {
	q [n] = a [n] + a [1] ;
	for (int i = 1 ; i < n ; i ++)
		q [i] = a [i] + a [i + 1] ;
	for (int i = 1 ; i <= n ; i ++)  a [i] = q [i] ;
}
bool log (int x , int y) {
	if (x == 0)  return 1 ;
	x *= 2 ; t ++ ;
	while (x < y)  x *= 2 , t ++ ;
	return x != y ;
}
bool check () {
	for (int i = 1 ; i <= n ; i ++)
		if (a [i] != b [i])  return 1 ;
	return 0 ;
}
main () { 
	cin >> n ;
	for (int i = 1 ; i <= n ; i ++)  cin >> a [i] , s1 += a [i] ;
	for (int i = 1 ; i <= n ; i ++)  cin >> b [i] , s2 += b [i] ;
	fl = 1 ; 
	for (int i = 1 ; i <= n ; i ++)
		if (a [i] != b [i]) {
			fl = 0 ; break ;  
		}
	if (fl)  return cout << "null" , 0 ;
	if (log (s1 , s2))  return cout << "No solution" , 0 ;
	for (int i = 1 ; i <= t ; i ++)  R () ;
	for (int i = 1 ; i <= n ; i ++)  cout << a [i] << " " ; 
	while (check ()) L () , la ++ ;
	if (la > t)  return cout << "No solution" , 0 ;
	ra = t - la ;
	for (int i = 1 ; i <= la ; i ++)  cout << "L" ;
	for (int i = 1 ; i <= ra ; i ++)  cout << "R" ;
	return 0 ;
}

@韩慈阳 少题面+题面id