結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー kpinkcatkpinkcat
提出日時 2023-09-25 02:16:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,212 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 201,216 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 02:16:22
合計ジャッジ時間 8,449 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 220 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:14: 警告: ‘sum1’ may be used uninitialized [-Wmaybe-uninitialized]
   49 |         sum1 += a[c-1]*a[c-1] + a[d-1]*a[d-1] -(a[c-1]+k)*(a[c-1]+k) -(a[d-1]-k)*(a[d-1]-k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:37:18: 備考: ‘sum1’ はここで定義されています
   37 |     int n, m, q, sum1;
      |                  ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;

/*
string chadd(string sum, ll x){
    ll up = 0, tmp = 0;
    if (sum.size() >= 6){
        up = stoll(sum.substr(0, sum.size() - 5));
        tmp = stoll(sum.substr(sum.size() - 5));
    } else if (sum != "") tmp = stoll(sum);
    else tmp = 0;
    tmp += x;
    if (tmp >= 1e5){
        up += tmp/1e5;
        tmp = tmp%100000;
    }
    sum = "";
    if (up) sum += to_string(up);
    string stmp = to_string(tmp);
    if (up) stmp = std::string(std::max(0, 5-(int)stmp.size()), '0') + stmp;
    sum += stmp;
    return sum;
}
*/
int main()
{
    int n, m, q, sum1;
    cin >> n >> m;
    vector<ll> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    cin >> q;
    for (auto x : a) sum1 += x*x;
    for (int i = 0; i < q; i++){
        ll c, k, d;
        //string sum1 = "";
        cin >> c >> k >> d;
        a[c-1] -= k;
        a[d-1] += k;
        sum1 += a[c-1]*a[c-1] + a[d-1]*a[d-1] -(a[c-1]+k)*(a[c-1]+k) -(a[d-1]-k)*(a[d-1]-k);
        cout << sum1 << "\n";
    }
}

0