結果
| 問題 |
No.2942 Sigma Music Game Level Problem
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-10-21 11:10:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,574 bytes |
| コンパイル時間 | 871 ms |
| コンパイル使用メモリ | 57,544 KB |
| 最終ジャッジ日時 | 2025-02-24 22:10:32 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:65:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
65 | scanf("%d%d%d", &n, &qn, &li);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:66:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
66 | for (int i = 0; i < n; i++) scanf("%d", as + i);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:77:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
77 | scanf("%d", &op);
| ~~~~~^~~~~~~~~~~
main.cpp:81:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
81 | scanf("%d", &l);
| ~~~~~^~~~~~~~~~
main.cpp:88:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
88 | scanf("%d%d", &l, &r), l--;
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:97:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
97 | scanf("%d", &m);
| ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2942.cc: No.2942 Sigma Music Game Level Problem - yukicoder
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1000000;
const int MAX_M = 200000;
/* typedef */
using ll = long long;
template <typename T>
struct BIT {
int n;
vector<T> bits;
BIT() {}
BIT(int _n) { init(_n); }
void init(int _n) {
n = _n;
bits.assign(n + 1, 0);
}
T sum(int x) {
x = min(x, n);
T s = 0;
while (x > 0) {
s += bits[x];
x -= (x & -x);
}
return s;
}
void add(int x, T v) {
if (x <= 0) return;
while (x <= n) {
bits[x] += v;
x += (x & -x);
}
}
};
/* global variables */
int as[MAX_N];
BIT<int> bit0;
BIT<ll> bit1;
/* subroutines */
/* main */
int main() {
int n, qn, li;
scanf("%d%d%d", &n, &qn, &li);
for (int i = 0; i < n; i++) scanf("%d", as + i);
bit0.init(MAX_M), bit1.init(MAX_M);
for (int i = 0; i < n; i++) {
bit0.add(as[i], 1);
bit1.add(as[i], as[i]);
}
int q2 = 0;
while (qn--) {
int op;
scanf("%d", &op);
if (op == 1) {
int l;
scanf("%d", &l);
bit0.add(l, 1);
bit1.add(l, l);
}
else if (op == 2) {
int l, r;
scanf("%d%d", &l, &r), l--;
int c = bit0.sum(r) - bit0.sum(l);
ll s = bit1.sum(r) - bit1.sum(l);
printf("%d %lld\n", c, s);
q2++;
}
else if (op == 3) {
int m;
scanf("%d", &m);
li = m;
}
}
if (q2 == 0) puts("Not Found!");
return 0;
}
tnakao0123