結果

問題 No.876 Range Compress Query
ユーザー ei1333333
提出日時 2019-09-06 23:13:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,778 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 2,851 ms
コンパイル使用メモリ 214,784 KB
最終ジャッジ日時 2025-01-07 16:57:37
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d %d", &N, &Q);
      |   ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%lld", &A[i]);
      |     ~~~~~^~~~~~~~~~~~~~~
main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |     scanf("%d %d %d", &a, &b, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:25:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |       scanf("%d", &d);
      |       ~~~~~^~~~~~~~~~

ソースコード

diff #

// とおってー!

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;


int main() {
  int N, Q;
  int64 A[100000];
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for(int i = 0; i < Q; i++) {
    int a, b, c, d;
    scanf("%d %d %d", &a, &b, &c);
    --b;
    if(a == 1) {
      scanf("%d", &d);
      for(int j = b; j < c; j++) A[j] += d;
    } else {
      int ret = 0;
      for(int j = b; j < c - 1; j++) ret += A[j] != A[j + 1];
      printf("%d\n", ret + 1);
    }
  }
}
0