Submission #59184498


Source Code Expand

Copy
#include <iostream>
#include <map>
#define int long long
using namespace std;
const int N=2e5+10;
int n,m;
int ans;
int a[N],b[N];
map<pair<int,int>,bool>mp;
int dx[8]={2,1,-1,-2,-2,-1,1,2},dy[8]={1,2,2,1,-1,-2,-2,-1};
signed main()
{
cin>>n>>m;
ans=m;
for(int i=1;i<=m;i++) cin>>a[i]>>b[i],mp[{a[i],b[i]}]=true;;
for(int j=1;j<=m;j++)
{
for(int i=0;i<8;i++)
{
int x=a[j]+dx[i],y=b[j]+dy[i];
if(x<=0||x>n||y<=0||y>n) continue;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <iostream>
#include <map>
#define int long long
using namespace std;
const int N=2e5+10;
int n,m;
int ans;
int a[N],b[N];
map<pair<int,int>,bool>mp;
int dx[8]={2,1,-1,-2,-2,-1,1,2},dy[8]={1,2,2,1,-1,-2,-2,-1};
signed main()
{
    cin>>n>>m;
    ans=m;
    for(int i=1;i<=m;i++)   cin>>a[i]>>b[i],mp[{a[i],b[i]}]=true;;
    for(int j=1;j<=m;j++)
    {
        for(int i=0;i<8;i++)
        {
            int x=a[j]+dx[i],y=b[j]+dy[i];
            if(x<=0||x>n||y<=0||y>n)    continue;
            else
            {
                if(mp[{x,y}]==false)    ans++,mp[{x,y}]=true;
            }
        }
    }
    cout<<n*n-ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - Avoid Knight Attack
User XiaoPeng1234
Language C++ 17 (gcc 12.2)
Score 300
Code Size 684 Byte
Status AC
Exec Time 995 ms
Memory 119268 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
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_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3464 KB
00_sample_01.txt AC 1 ms 3460 KB
00_sample_02.txt AC 1 ms 3444 KB
01_random_03.txt AC 481 ms 19212 KB
01_random_04.txt AC 804 ms 60672 KB
01_random_05.txt AC 995 ms 119092 KB
01_random_06.txt AC 779 ms 119120 KB
01_random_07.txt AC 730 ms 119268 KB
01_random_08.txt AC 743 ms 119088 KB
01_random_09.txt AC 92 ms 8856 KB
01_random_10.txt AC 510 ms 39496 KB
01_random_11.txt AC 447 ms 63308 KB
01_random_12.txt AC 38 ms 11908 KB
01_random_13.txt AC 536 ms 89612 KB
01_random_14.txt AC 71 ms 17708 KB
01_random_15.txt AC 1 ms 3492 KB
01_random_16.txt AC 1 ms 3492 KB
01_random_17.txt AC 1 ms 3440 KB
01_random_18.txt AC 1 ms 3380 KB
01_random_19.txt AC 1 ms 3504 KB
01_random_20.txt AC 1 ms 3444 KB
01_random_21.txt AC 1 ms 3464 KB
01_random_22.txt AC 1 ms 3504 KB
01_random_23.txt AC 459 ms 19272 KB
01_random_24.txt AC 760 ms 49096 KB
01_random_25.txt AC 740 ms 70636 KB
01_random_26.txt AC 649 ms 70560 KB
01_random_27.txt AC 655 ms 70748 KB
01_random_28.txt AC 673 ms 70644 KB
01_random_29.txt AC 3 ms 3892 KB
01_random_30.txt AC 94 ms 8844 KB
01_random_31.txt AC 385 ms 60676 KB
01_random_32.txt AC 15 ms 6496 KB
01_random_33.txt AC 1 ms 3536 KB
01_random_34.txt AC 277 ms 49996 KB


2025-03-28 (Fri)
11:24:34 +00:00