forked from imabhinav-am/Competetive-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommands3.cpp
More file actions
45 lines (44 loc) · 677 Bytes
/
Commands3.cpp
File metadata and controls
45 lines (44 loc) · 677 Bytes
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
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct cmd
{
int no;
int lw;
int up;
};
int ctr=0;
void calc(vector<int> &A,vector<cmd> &Cmd,int x,int y)
{
for(int i=x-1;i<y;i++)
{
if(Cmd[i].no==1)
fill(A.begin()+Cmd[i].lw-1,A.begin()+Cmd[i].up,++A.at(Cmd[i].lw-1));
if(Cmd[i].no==2)
calc(A,Cmd,Cmd[i].lw,Cmd[i].up);
}
}
int main()
{
int n,N,M;
cin>>n;
while(n>0)
{
cin>>N>>M;
vector<int> A(N,0);
vector<cmd> Cmd;
for(int i=0;i<M;i++)
{
Cmd.push_back(cmd());
cin>>Cmd[i].no;
cin>>Cmd[i].lw;
cin>>Cmd[i].up;
}
calc(A,Cmd,1,M);
for(int i=0;i<N;i++)
cout<<A.at(i)<<" ";
cout<<endl;
n--;
}
}