Submission #36611101


Source Code Expand

#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define ldb long double
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 2e5 + 10;
inline int read()
{
  int s = 0, w = 1;
  char ch = getchar();
  while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int n, Q;
int a[N], tim[N];
signed main()
{
  n = read();
  for(re int i = 1; i <= n; i++) a[i] = read();
  Q = read();
  int t = -1, v;
  for(re int i = 1; i <= Q; i++){
    int op = read(), x, y;
    if(op == 1) t = i, v = read();
    if(op == 2){
      x = read(), y = read();
      if(tim[x] < t) tim[x] = i, a[x] = v;
      a[x] += y;
    }
    if(op == 3){
      x = read();
      if(tim[x] < t) tim[x] = i, a[x] = v;
      printf("%lld\n", a[x]);
    }
  }
  return 0;
}

Submission Info

Submission Time
Task D - All Assign Point Add
User Booksnow
Language C++ (GCC 9.2.1)
Score 400
Code Size 1078 Byte
Status AC
Exec Time 40 ms
Memory 6700 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   28 |   for(re int i = 1; i <= n; i++) a[i] = read();
      |              ^
./Main.cpp:31:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   31 |   for(re int i = 1; i <= Q; i++){
      |              ^
./Main.cpp:41:39: warning: ‘v’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |       if(tim[x] < t) tim[x] = i, a[x] = v;
      |                                  ~~~~~^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_N_small_03.txt, 01_N_small_04.txt, 01_N_small_05.txt, 01_N_small_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 03_max_11.txt, 04_handmade_12.txt, 04_handmade_13.txt, 04_handmade_14.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 8 ms 3600 KiB
00_sample_01.txt AC 2 ms 3484 KiB
00_sample_02.txt AC 2 ms 3756 KiB
01_N_small_03.txt AC 20 ms 3528 KiB
01_N_small_04.txt AC 15 ms 3416 KiB
01_N_small_05.txt AC 22 ms 3536 KiB
01_N_small_06.txt AC 26 ms 3596 KiB
02_random_07.txt AC 25 ms 5224 KiB
02_random_08.txt AC 27 ms 6076 KiB
02_random_09.txt AC 19 ms 5100 KiB
02_random_10.txt AC 36 ms 5696 KiB
03_max_11.txt AC 40 ms 6648 KiB
04_handmade_12.txt AC 29 ms 4484 KiB
04_handmade_13.txt AC 24 ms 4260 KiB
04_handmade_14.txt AC 38 ms 6700 KiB