Idea: What Bao Ge said during the competition is right, that is, when the number is 2 operations, the number is first put into the array, and then unified computing is performed when the query is output, however, at that time, it was so bad that debugging went on for two days ......
The vector written in the morning forgot to clear it when Pushdown. Then, after MLE got down early in the morning, Nima thought the array was too large and then changed it to a struct, or MLE, finally, I handed in other people's code and found that there was no MLE. I went crazy for a noon and found this error only when I was bored. Nima ...... How can I find my debugging so weak ......
Another issue that needs to be noted is that operations 1 and 2 are prone to errors, which is also the reason why I spent one afternoon in wa ...... Alas ......
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <map> # include <queue> # include <set> # include <cmath> # include <bitset> # define MEM (, b) memset (a, B, sizeof (A) # define lson I <1, L, mid # define rson I <1 | 1, Mid + 1, R # define INF 510010 # define maxn 400010 using namespace STD; typedef long ll; typedef unsigned long ull; int key [maxn]; short lazy [maxn]; vector <int> ve [maxn]; int n, m; int Gcd (int A, int B) {return! B? A: gcd (B, A % B);} void Pushdown (int I, int L, int R) {If (L = r) return; if (lazy [I] = 1) {key [I <1] = Key [I <1 | 1] = Key [I]; lazy [I <1] = lazy [I <1 | 1] = lazy [I]; ve [I <1] = ve [I <1 | 1] = ve [I]; lazy [I] = 0;} else {for (Int J = 0; j <ve [I]. size (); j ++) {ve [I <1]. push_back (VE [I] [J]); ve [I <1 | 1]. push_back (VE [I] [J]);} ve [I]. clear ();} void Update (int I, int L, int R, int L, int R, int V, int c) {Pushdown (I, L, R ); if (L = L & R = r) {I F (C = 1) lazy [I] = 1, key [I] = V, ve [I]. clear (); else ve [I]. push_back (V); return;} int mid = (L + r)> 1; if (r <= mid) Update (lson, L, R, V, C ); else if (L> mid) Update (rson, L, R, V, c); else {Update (lson, L, mid, V, c); Update (rson, mid + 1, R, V, c) ;}} void query (int I, int L, int R) {Pushdown (I, L, R ); if (L = r) {for (Int J = 0; j <ve [I]. size (); j ++) {If (Key [I]> ve [I] [J]) Key [I] = gcd (Key [I], ve [I] [J]); If (Key [I] = 1) break;} printf (" % D ", key [I]); return;} int mid = (L + r)> 1; query (lson); query (rson );} void build (int I, int L, int R) {key [I] = lazy [I] = 0; ve [I]. clear (); If (L = r) {scanf ("% d", & Key [I]); return;} int mid = (L + r)> 1; build (lson); Build (rson);} void debug (int I, int L, int R) {printf ("node: % 3d range: % 3d ~~ % 3d pass value: % 11d MARK: % 3d \ n ", I, L, R, key [I], lazy [I]); If (L = r) return; int mid = (L + r)> 1; debug (lson); debug (rson);} int main () {// freopen ("test.txt ", "r", stdin); int t; CIN> T; while (t --) {int I; scanf ("% d", & N); Build (1,1, n); scanf ("% d", & M); While (M --) {int C, L, R, X; scanf ("% d", & C, & L, & R, & X); Update (1, 1, n, l, R, X, c); // debug (, n); // puts ("");} query (, n); puts ("") ;}return 0 ;}