Submission #43894298


Source Code Expand

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define Ls(i,l,r) for(int i=l;i<r;++i)
#define Rs(i,l,r) for(int i=l;i>r;--i)
#define Le(i,l,r) for(int i=l;i<=r;++i)
#define Re(i,l,r) for(int i=l;i>=r;--i)
#define L(i,l) for(int i=0;i<l;++i)
#define E(i,l) for(int i=1;i<=l;++i)
#define W(t) while(t--)
const int N=3010;
int n,m,k,f[2][N];
typedef long long ll;
ll ans;
bool st[N][N];
int main(){
    #ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
    // freopen("1.out","w",stdout);
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    #endif
    // Insert Code Here
    scanf("%d%d%d",&n,&m,&k);
    E(i, k){
        int a,b;
        scanf("%d%d",&a,&b);
        st[a][b]=1;
    }
    E(i, n){
        E(j, m){
            if(st[i][j]){
                f[i&1][j]=0;
                continue;
            }
            f[i&1][j]=min(f[i-1&1][j-1],min(f[i-1&1][j],f[i&1][j-1]))+1;
            ans+=f[i&1][j];
        }
    }
    printf("%lld",ans);
    return 0;
}

Submission Info

Submission Time
Task E - Defect-free Squares
User WUSICHENG
Language C++ (GCC 9.2.1)
Score 475
Code Size 1062 Byte
Status AC
Exec Time 68 ms
Memory 10520 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:38:30: warning: suggest parentheses around ‘-’ in operand of ‘&’ [-Wparentheses]
   38 |             f[i&1][j]=min(f[i-1&1][j-1],min(f[i-1&1][j],f[i&1][j-1]))+1;
      |                             ~^~
./Main.cpp:38:48: warning: suggest parentheses around ‘-’ in operand of ‘&’ [-Wparentheses]
   38 |             f[i&1][j]=min(f[i-1&1][j-1],min(f[i-1&1][j],f[i&1][j-1]))+1;
      |                                               ~^~
./Main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
./Main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 4
AC × 26
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 02_max_00.txt, 02_max_01.txt, 02_max_02.txt, 03_sparse_00.txt, 03_sparse_01.txt, 03_sparse_02.txt, 03_sparse_03.txt, 03_sparse_04.txt, 03_sparse_05.txt, 03_sparse_06.txt, 03_sparse_07.txt, 03_sparse_08.txt, 03_sparse_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 4 ms 1724 KiB
00_sample_01.txt AC 1 ms 1716 KiB
00_sample_02.txt AC 2 ms 1684 KiB
00_sample_03.txt AC 40 ms 1688 KiB
01_random_00.txt AC 2 ms 1644 KiB
01_random_01.txt AC 8 ms 5020 KiB
01_random_02.txt AC 3 ms 4856 KiB
01_random_03.txt AC 1 ms 1716 KiB
01_random_04.txt AC 64 ms 10520 KiB
01_random_05.txt AC 26 ms 6056 KiB
01_random_06.txt AC 1 ms 1652 KiB
01_random_07.txt AC 42 ms 10512 KiB
01_random_08.txt AC 19 ms 6556 KiB
02_max_00.txt AC 68 ms 10480 KiB
02_max_01.txt AC 62 ms 10460 KiB
02_max_02.txt AC 62 ms 10488 KiB
03_sparse_00.txt AC 35 ms 1688 KiB
03_sparse_01.txt AC 35 ms 1656 KiB
03_sparse_02.txt AC 35 ms 1732 KiB
03_sparse_03.txt AC 31 ms 1644 KiB
03_sparse_04.txt AC 37 ms 1664 KiB
03_sparse_05.txt AC 34 ms 1656 KiB
03_sparse_06.txt AC 35 ms 1744 KiB
03_sparse_07.txt AC 35 ms 1640 KiB
03_sparse_08.txt AC 35 ms 1740 KiB
03_sparse_09.txt AC 35 ms 1692 KiB