제출 #1003413

#제출 시각아이디문제언어결과실행 시간메모리
1003413vjudge1ZIGZAG (INOI20_zigzag)C++17
0 / 100
16 ms13660 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define int ll #define MAX 100001 #define INF INT_MAX #define MOD 1000000007 #define mp make_pair #define mt make_tuple #define pb push_back #define ins insert #define ff first #define ss second #define all(a) a.begin(),a.end() #define lb(a,b) lower_bound(all(a),b) #define ub(a,b) upper_bound(all(a),b) #define sortv(a) sort(all(a)) #define outputar(a,b){\ for(int i=0;i<b;i++){\ cout << a[i] << " ";\ }\ cout << endl;\ } #define outputvec(a){\ for(auto x:a){\ cout << (int)x << " ";\ }\ cout << endl;\ } #define reset(a,n,v){\ for(int i=0;i<n;i++){\ a[i]=v;\ }\ } using namespace std; typedef long long ll; typedef unsigned long long ull; typedef tuple<ll,ll,ll> tll; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef double db; typedef long double ldb; inline void USACO(string filename){ freopen((filename+".in").c_str(),"r",stdin); freopen((filename+".out").c_str(),"w",stdout); } int n,q,t=1,m,k,x,y,z,x2,y2,z2,a[MAX],b[MAX],d[MAX],e[MAX]; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string s[MAX],str[MAX]; //int e[1001][1001]; string s1,s2,s3; const int mod = 998244353; int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; void solve(){ cin >> n >> q; for(int i=0;i<n;i++){ cin >> a[i]; } for(int i=0;i<q;i++){ char d; cin >> d; if(d=='?'){ cin >> x >> y; x--; y--; vector<int> c; for(int j=x+1;j<=y;j++){ if(a[j]>a[j-1]){ c.pb(1); } else if(a[j]<a[j-1]){ c.pb(0); } else{ c.pb(2); } } int sz=(int)c.size(); for(int j=0;j<sz;j++){ b[j]=0; } if(c[0]!=2){ b[0]=1; } for(int j=1;j<sz;j++){ if(c[j]!=2){ b[j]=1; if(c[j-1]==1-c[j]){ b[j]+=b[j-1]; } } } int res=y-x+1; for(int j=0;j<sz;j++){ res+=b[j]; } cout << res << "\n"; } else if(d=='+'){ cin >> x >> y >> z; x--; y--; for(int j=x;j<=y;j++){ a[j]+=z; } } else{ cin >> x >> y; x--; y--; for(int j=x;j<=y;j++){ a[j]*=-1; } } } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input13.txt","r",stdin); //cin >> t; ll cnt1=1; while(t--){ solve(); cnt1++; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...