Submission #36619694


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 = 3e2 + 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, m, V, x, y, A;
int mx[N], cnt[N], a[N][N];
signed main()
{
  n = read(), m = read(), V = read(), x = read(), y = read();
  for(re int i = 1; i <= n; i++)
    for(re int j = 1; j <= m; j++) a[i][j] = read();
  for(re int i = 1; i <= n; i++){
    for(re int j = 1; j <= m; j++){
      if(!mx[a[i][j]]) A += 1;
      mx[a[i][j]] += 1;
    }
  }
  for(re int t = 1; t <= n - x + 1; t++){
    for(re int c = 1; c <= V; c++) cnt[c] = 0;
  //  cout << cnt[]
    int ans = 0;
    for(re int i = t; i <= t + x - 1; i++){
      for(re int j = 1; j <= y; j++){
       // if(a[i][j] == 5) cout << "Yes\n";
        cnt[a[i][j]] += 1;
        if(cnt[a[i][j]] == mx[a[i][j]]) ans += 1;
      }
    }
    printf("%lld ", A - ans);
    //cout << "Begin: " << t << "\n";
    for(re int j = y + 1; j <= m; j++){
      //cout << j << " " << j - y << "\n";
      for(re int i = t; i <= t + x - 1; i++){
        if(cnt[a[i][j - y]] == mx[a[i][j - y]]) ans -= 1;
        cnt[a[i][j - y]] -= 1;
        cnt[a[i][j]] += 1;
        if(cnt[a[i][j]] == mx[a[i][j]]) ans += 1;
      }
     // cout << cnt[5] << " " << cnt[4] << " " << ans << "\n";
      printf("%lld ", A - ans);
    }
    puts("");
  }
  return 0;
}

Submission Info

Submission Time
Task E - Grid Filling
User Booksnow
Language C++ (GCC 9.2.1)
Score 500
Code Size 1813 Byte
Status AC
Exec Time 24 ms
Memory 4388 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++)
      |              ^
./Main.cpp:29:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   29 |     for(re int j = 1; j <= m; j++) a[i][j] = read();
      |                ^
./Main.cpp:30:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   30 |   for(re int i = 1; i <= n; i++){
      |              ^
./Main.cpp:31:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   31 |     for(re int j = 1; j <= m; j++){
      |                ^
./Main.cpp:36:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   36 |   for(re int t = 1; t <= n - x + 1; t++){
      |              ^
./Main.cpp:37:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   37 |     for(re int c = 1; c <= V; c++) cnt[c] = 0;
      |                ^
./Main.cpp:40:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   40 |     for(re int i = t; i <= t + x - 1; i++){
      |                ^
./Main.cpp:41:18: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   41 |       for(re int j = 1; j <= y; j++){
      |                  ^
./Main.cpp:49:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   49 |     for(re int j = y + 1; j <= m; j++){
      |                ^
./Main.cpp:51:18: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   51 |       for(re int i = t; i <= t + x - 1; i++){
      |                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 24
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_small_03.txt, 01_small_04.txt, 01_small_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 03_max_12.txt, 03_max_13.txt, 03_max_14.txt, 03_max_15.txt, 04_edge_16.txt, 04_edge_17.txt, 04_edge_18.txt, 04_edge_19.txt, 04_edge_20.txt, 04_edge_21.txt, 04_edge_22.txt, 04_edge_23.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 7 ms 3660 KiB
00_sample_01.txt AC 2 ms 3660 KiB
00_sample_02.txt AC 3 ms 3640 KiB
01_small_03.txt AC 2 ms 3556 KiB
01_small_04.txt AC 3 ms 3564 KiB
01_small_05.txt AC 2 ms 3636 KiB
02_random_06.txt AC 2 ms 4020 KiB
02_random_07.txt AC 17 ms 4120 KiB
02_random_08.txt AC 4 ms 3540 KiB
02_random_09.txt AC 2 ms 3628 KiB
02_random_10.txt AC 2 ms 3632 KiB
02_random_11.txt AC 4 ms 4064 KiB
03_max_12.txt AC 20 ms 4256 KiB
03_max_13.txt AC 23 ms 4288 KiB
03_max_14.txt AC 24 ms 4388 KiB
03_max_15.txt AC 15 ms 4280 KiB
04_edge_16.txt AC 16 ms 4280 KiB
04_edge_17.txt AC 12 ms 4384 KiB
04_edge_18.txt AC 16 ms 4348 KiB
04_edge_19.txt AC 17 ms 4280 KiB
04_edge_20.txt AC 19 ms 4292 KiB
04_edge_21.txt AC 11 ms 4284 KiB
04_edge_22.txt AC 8 ms 4352 KiB
04_edge_23.txt AC 18 ms 4388 KiB