#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt") #define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 4e5+10;int n,m;vector<int> paths[mxn];int deg[mxn];queue<int> q;int arr[mxn];map<pii,int> mp; inline bool check(int tar){ for(int i = 0;i+n<=tar;i++){ paths[i+n].push_back(i); deg[i]++; } for(int i = 0;i+m<=tar;i++){ paths[i].push_back(i+m); deg[i+m]++; } for(int i = 0;i<=tar;i++){ if(!deg[i])q.push(i); } int p = 0; while(!q.empty()){ auto now = q.front(); arr[now] = ++p; q.pop(); for(auto nxt:paths[now]){ deg[nxt]--; if(!deg[nxt])q.push(nxt); } } for(int i = 0;i<=tar;i++){ paths[i].clear(); deg[i] = 0; } return p == tar+1;} inline void solve(){ cin>>n>>m; int l = 0,r = max(n,m)*2; if(mp.find({n,m}) != mp.end()){ l = r = mp[make_pair(n,m)]; } l = r = n+m-__gcd(n,m)-1; while(l != r){ int mid = (l+r+1)>>1; if(check(mid))l = mid; else r = mid-1; } check(l); cout<<l<<endl; return; mp[make_pair(n,m)] = l; for(int i =1;i<=l;i++)cout<<arr[i]-arr[i-1]<<' ';cout<<'\n'; return;} int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--)solve();}
Compilation message
sequence.cpp:4:35: error: stray '#' in program
4 | #pragma GCC target("avx2,popcnt") #define ll long long
| ^
sequence.cpp:4:36: error: '#pragma GCC target' string is badly formed
4 | #pragma GCC target("avx2,popcnt") #define ll long long
| ^~~~~~