提出 #74893240


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,char> pic;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef priority_queue<int,vi,greater<int>> mipqint;//小根堆
typedef priority_queue<int> pqint;//大根堆
#define SZ(x) ((int)x.size())
const int mod = 1e9+7;
const int P = 998244353;
const int md = 101;
const ll inf = (1LL << 60LL);
const int N = 4e6+10;
const int MAX_NODE = 1e7+10;


struct Node {
    int l, r;  
    ll sum; 
} tr[MAX_NODE];

int root[N];
int tot = 0;

int build(int l, int r) {
    int p = ++tot;
    tr[p].sum = 0;
    if (l == r) 
		return p;
    int mid = (l + r) >> 1;
    tr[p].l = build(l, mid);
    tr[p].r = build(mid+1, r);
    return p;
}
int update(int p, int l, int r, int pos, ll val) {
    int q = ++tot;
    tr[q] = tr[p];         
    tr[q].sum = val;
    if (l == r) 
		return q;
    int mid = (l + r) >> 1;
    if (pos <= mid) 
		tr[q].l = update(tr[p].l, l, mid, pos, val);
    else 
		tr[q].r = update(tr[p].r, mid+1, r, pos, val);
    tr[q].sum = tr[tr[q].l].sum + tr[tr[q].r].sum;
    return q;
}
ll query(int p, int l, int r, int L, int R) {
    if (L <= l && r <= R) 
		return tr[p].sum;
    int mid = (l + r) >> 1;
    ll res = 0;
    if (L <= mid) 
		res += query(tr[p].l, l, mid, L, R);
    if (R > mid) 
		res += query(tr[p].r, mid+1, r, L, R);
    return res;
}
int n, m, Q;
signed main() {
    
    scanf("%lld%lld%lld",&n,&m,&Q);
   
    for (int i = 1; i <= n; ++i) {
        root[i] = build(1, m);
    }
    
    while (Q--) {
        int opt;
        cin >> opt;
        if (opt == 1) {
            int x, y;
            scanf("%lld%lld",&x,&y);
            root[x] = root[y];
        } 
		else if (opt == 2) {
            int x, y; ll Z;
            cin >> x >> y >> Z;
            root[x] = update(root[x], 1, m, y, Z);
        } 
		else if (opt == 3) {
            int x, L, R;
            scanf("%lld%lld%lld",&x,&L,&R);
           	printf("%lld\n",query(root[x], 1, m, L, R));
        }
    }
    
    return 0;
}

提出情報

提出日時
問題 G - Copy Query
ユーザ wuqize
言語 C++23 (GCC 15.2.0)
得点 0
コード長 2240 Byte
結果 MLE
実行時間 561 ms
メモリ > 1048576 KiB

コンパイルエラー

./Main.cpp: In function 'int main()':
./Main.cpp:69:15: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   69 |     scanf("%lld%lld%lld",&n,&m,&Q);
      |            ~~~^          ~~
      |               |          |
      |               |          int*
      |               long long int*
      |            %d
./Main.cpp:69:19: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
   69 |     scanf("%lld%lld%lld",&n,&m,&Q);
      |                ~~~^         ~~
      |                   |         |
      |                   |         int*
      |                   long long int*
      |                %d
./Main.cpp:69:23: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
   69 |     scanf("%lld%lld%lld",&n,&m,&Q);
      |                    ~~~^        ~~
      |                       |        |
      |                       |        int*
      |                       long long int*
      |                    %d
./Main.cpp:80:23: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   80 |             scanf("%lld%lld",&x,&y);
      |                    ~~~^      ~~
      |                       |      |
      |                       |      int*
      |                       long long int*
      |                    %d
./Main.cpp:80:27: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
   80 |             scanf("%lld%lld",&x,&y);
      |                        ~~~^     ~~
      |                           |     |
      |                           |     int*
      |                           long long int*
      |                        %d
./Main.cpp:90:23: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   90 |             scanf("%lld%lld%lld",&x,&L,&R);
      |                    ~~~^          ~~
      |                       |          |
      |                       |          int*
      |                       long long int*
      |                    %d
./Main.cpp:90:27: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
   90 |             scanf("%lld%lld%lld",&x,&L,&R);
      |                        ~~~^         ~~
      |                           |         |
      |                           |         int*
      |                           long long int*
      |                        %d
./Main.cpp:90:31: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
   90 |             scanf("%lld%lld%lld",&x,&L,&R);
      |                            ~~~^        ~~
      |                               |        |
      |                               |        int*
      |                               long long int*
      |                            %d

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 600
結果
MLE × 1
AC × 2
MLE × 24
セット名 テストケース
Sample sample_01.txt
All evil_01.txt, evil_02.txt, evil_03.txt, evil_04.txt, evil_05.txt, sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt
ケース名 結果 実行時間 メモリ
evil_01.txt MLE 541 ms > 1048576 KiB
evil_02.txt MLE 561 ms > 1048576 KiB
evil_03.txt MLE 537 ms > 1048576 KiB
evil_04.txt MLE 536 ms > 1048576 KiB
evil_05.txt MLE 532 ms > 1048576 KiB
sample_01.txt MLE 530 ms > 1048576 KiB
test_01.txt AC 3 ms 3608 KiB
test_02.txt MLE 527 ms > 1048576 KiB
test_03.txt AC 1 ms 3756 KiB
test_04.txt MLE 530 ms > 1048576 KiB
test_05.txt MLE 528 ms > 1048576 KiB
test_06.txt MLE 530 ms > 1048576 KiB
test_07.txt MLE 529 ms > 1048576 KiB
test_08.txt MLE 532 ms > 1048576 KiB
test_09.txt MLE 528 ms > 1048576 KiB
test_10.txt MLE 530 ms > 1048576 KiB
test_11.txt MLE 529 ms > 1048576 KiB
test_12.txt MLE 531 ms > 1048576 KiB
test_13.txt MLE 528 ms > 1048576 KiB
test_14.txt MLE 530 ms > 1048576 KiB
test_15.txt MLE 526 ms > 1048576 KiB
test_16.txt MLE 528 ms > 1048576 KiB
test_17.txt MLE 527 ms > 1048576 KiB
test_18.txt MLE 529 ms > 1048576 KiB
test_19.txt MLE 530 ms > 1048576 KiB
test_20.txt MLE 530 ms > 1048576 KiB