#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
struct oper
{
int t,a,b;
void print()
{
if(t == 3) cout << t << " " << a << "\n";
else cout << t << " " << a << " " << b << "\n";
}
};
vector<oper> opers;
vector<bitset<50001>> sets;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//random_start();
int n,s;
cin >> n >> s;
bitset<50001> cur;
sets.pb(cur);
rep2(i,1,n)
{
rep3(j,i,n,i)
{
cur[j] = 1;
}
sets.pb(cur);
rep3(j,i,n,i)
{
cur[j] = 0;
}
}
opers.pb({3,1,1});
sets.pb(cur);
bitset<50001> B;
rep(i,s)
{
int x;
cin >> x;
B[x] = 1;
}
rep2(i,1,n)
{
if(B[i] != cur[i])
{
if(cur[i] == 0)
{
opers.pb({1,siz(sets)-1,i});
cur |= sets[i];
sets.pb(cur);
}
else
{
opers.pb({3,i});
opers.pb({2,siz(sets),siz(sets)-1});
bitset<50001> new_b = sets[i];
new_b.flip();
sets.pb(new_b);
cur &= new_b;
sets.pb(cur);
}
}
}
cout << siz(opers) << "\n";
forall(it,opers)
{
it.print();
}
}
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 | #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define ull unsigned long long #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vl vector<long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define siz(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; //mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll los(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; struct oper { int t,a,b; void print() { if(t == 3) cout << t << " " << a << "\n"; else cout << t << " " << a << " " << b << "\n"; } }; vector<oper> opers; vector<bitset<50001>> sets; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //random_start(); int n,s; cin >> n >> s; bitset<50001> cur; sets.pb(cur); rep2(i,1,n) { rep3(j,i,n,i) { cur[j] = 1; } sets.pb(cur); rep3(j,i,n,i) { cur[j] = 0; } } opers.pb({3,1,1}); sets.pb(cur); bitset<50001> B; rep(i,s) { int x; cin >> x; B[x] = 1; } rep2(i,1,n) { if(B[i] != cur[i]) { if(cur[i] == 0) { opers.pb({1,siz(sets)-1,i}); cur |= sets[i]; sets.pb(cur); } else { opers.pb({3,i}); opers.pb({2,siz(sets),siz(sets)-1}); bitset<50001> new_b = sets[i]; new_b.flip(); sets.pb(new_b); cur &= new_b; sets.pb(cur); } } } cout << siz(opers) << "\n"; forall(it,opers) { it.print(); } } |
English