結果

問題 No.879 Range Mod 2 Query
ユーザー HIR180HIR180
提出日時 2019-09-07 00:53:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,273 ms / 3,000 ms
コード長 1,137 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 36,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 05:07:56
合計ジャッジ時間 11,134 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 591 ms
4,376 KB
testcase_12 AC 335 ms
4,376 KB
testcase_13 AC 424 ms
4,376 KB
testcase_14 AC 438 ms
4,380 KB
testcase_15 AC 348 ms
4,376 KB
testcase_16 AC 1,103 ms
4,376 KB
testcase_17 AC 1,200 ms
4,376 KB
testcase_18 AC 1,158 ms
4,376 KB
testcase_19 AC 1,166 ms
4,380 KB
testcase_20 AC 1,204 ms
4,380 KB
testcase_21 AC 1,273 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations")
#pragma GCC target("avx")
#include <stdio.h>
inline int read_char() {
    static char buf[1 << 16], *ptr = buf, *end_ptr = buf;
    if (ptr == end_ptr) {
        int len = fread(buf, 1, sizeof(buf), stdin);
        if (len <= 0) return EOF;
        ptr = buf;
        end_ptr = buf + len;
    }
    return *ptr++;
}
 
inline int read_int() {
    int ch; bool sg = 0;
    do {
        ch = read_char();
        if (ch == '-') sg = 1;
    } while (ch < '0' || ch > '9');
    int x = ch - '0';
    while (true) {
        ch = read_char();
        if (ch < '0' || ch > '9') break;
        x = x * 10 + ch - '0';
    }
    return (sg?-x:x);
}
 
long long a[100005],ans;
int n,m,t,l,r,x;
int main(){
	n=read_int(); m=read_int();
	for(int i=1;i<=n;i++) a[i]=read_int();
	for(int i=1;i<=m;i++){
		t=read_int(); l=read_int(); r=read_int();
		if(t == 1){
			for(int j=l;j<=r;j++) a[j] &= 1;
		}
		else if(t == 3){
			ans=0;
			for(int j=l;j<=r;j++) ans+=a[j];
			printf("%lld\n",ans);
		}
		else{
			x=read_int();
			for(int j=l;j<=r;j++) a[j] += x;
		}
	}
}
0