1 #include "stdafx.h" 2 #include <iostream> 3 #include <vector> 4 using namespace std; 5 6 int _tmain(int argc, _TCHAR* argv[]) 7 { 8 int times; 9 cin>>times; 10 for(int i=0;i<times;i++) 11 { 12 int len; 13 int command; 14 cin>>len>>command; 15 vector<int> array(len); 16 for(int j=0;j<len;j++) 17 { 18 cin>>array[j]; 19 } 20 for(int k=0;k<command;k++) 21 { 22 char cmd; 23 int param1,param2; 24 cin>>cmd>>param1>>param2; 25 if(cmd=='Q') 26 { 27 int sum=0; 28 for(param1=param1-1;param1<param2;param1++) 29 { 30 sum=sum+array[param1]; 31 } 32 cout<<sum; 33 } 34 if(cmd=='C') 35 { 36 for(param1=param1-1;param1<param2;param1++) 37 { 38 array[param1]==1?0:1; 39 } 40 } 41 } 42 cout<<"\n\n"; 43 } 44 return 0; 45 }