Submission #3551053


Source Code Expand

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
const ll p = 1000000007;
ll dx[4] = {-7,-1,1,7};
ll N,M,Q;
static ll a[100002] = {};
static bool grid[700003] = {};
static bool visited[700003] = {};
static bool visited2[700003] = {};

void dfs0(ll pos){
    if (visited[pos]) return;
    visited[pos] = true;

    REP(k,4){
        ll next = pos + dx[k];
        if (next >= 7*N) continue;
        if (next < 0) continue;
        if ((k==1) and (pos % 7 == 0)) continue;
        if ((k==2) and (pos % 7 == 6)) continue;
        if (grid[next]) continue;
        if (visited[next]) continue;
        dfs0(next);
    }

    return;
}

void dfs1(ll pos){
    if (visited[pos]) return;
    visited[pos] = true;

    REP(k,4){
        ll next = pos + dx[k];
        if (next >= M) continue;
        if (next < 0) continue;
        if ((k==1) and (pos % 7 == 0)) continue;
        if ((k==2) and (pos % 7 == 6)) continue;
        if (grid[next]) continue;
        if (visited[next]) continue;
        dfs1(next);
    }

    return;
}

void dfs2(ll pos){
    if (visited2[pos]) return;
    visited2[pos] = true;

    REP(k,4){
        ll next = pos + dx[k];
        if (next >= 2*M) continue;
        if (next < 0) continue;
        if ((k==1) and (pos % 7 == 0)) continue;
        if ((k==2) and (pos % 7 == 6)) continue;
        if (grid[next]) continue;
        if (visited2[next]) continue;
        dfs2(next);
    }

    return;
}



int main(){
    SCLLD3(N,M,Q);
    ARSCD(a,Q);

    REP(q,Q){
        ll ai = a[q];
        ll k = 0;
        while(k*M + ai <= 700001){
            grid[k*M+ai] = true;
            k++;
        }
    }

    if (N <= 100000){ // #1
        ll count = 0;
        FORq(i,0,7*N-1){
            if ((grid[i] == false) and (visited[i] == false)){
                dfs0(i);
                count++;
            }
        }

        PRINTLLD(count);
        return 0;
    }

/*     FORq(i,0,2*M-1){
        if (i % 7 == 0) printf("\n");
        if (grid[i]) printf("%d",1);
        else printf("%d",0);
    }
    printf("\n"); */

    ll count1 = 0;
    ll count2 = 0;

    FORq(i,0,M-1){
        if ((grid[i] == false) and (visited[i] == false)){
            dfs1(i);
            count1++;
        }
    }
    //printf("count1 = %lld\n",count1);

    FORq(i,0,2*M-1){
        if ((grid[i] == false) and (visited2[i] == false)){
            dfs2(i);
            count2++;
        }
    }

    //printf("count2 = %lld\n",count2);
    ll A,B;
    A = count2 - count1;
    B = count1 - A;
    ll c = 7*N / M;
    PRINTLLD(A*c + B);
}

Submission Info

Submission Time
Task C - Calendar 2
User Lithium
Language C++14 (GCC 5.4.1)
Score 390
Code Size 3834 Byte
Status WA
Exec Time 23 ms
Memory 13568 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:7:29: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=]
 #define SCD(n) scanf("%d",&n)
                             ^
./Main.cpp:15:29: note: in expansion of macro ‘SCD’
 #define ARSCD(A,N) REP(i,N){SCD(A[i]);}
                             ^
./Main.cpp:99:5: note: in expansion of macro ‘ARSCD’
     ARSCD(a,Q);
     ^
./Main.cpp:98:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     SCLLD3(N,M,Q);
                  ^
./Main.cpp:15:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 #define ARSCD(A,N) REP(i,N){SCD(A[i]);}
                                      ^
./Main.cpp:99:5: note: in expansion of macro ‘ARSCD’
     ARSCD(a,Q);
     ^

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 0 / 0 100 / 100 90 / 90 200 / 200 0 / 110
Status
AC × 2
AC × 7
AC × 1
AC × 3
AC × 10
WA × 2
Set Name Test Cases
Sample sub0_in1.txt, sub0_in2.txt
Subtask1 sub0_in1.txt, sub0_in2.txt, sub1_in1.txt, sub1_in2.txt, sub1_in3.txt, sub1_in4.txt, sub1_in5.txt
Subtask2 sub2_in1.txt
Subtask3 sub2_in1.txt, sub3_in1.txt, sub3_in2.txt
Subtask4 sub0_in1.txt, sub0_in2.txt, sub1_in1.txt, sub1_in2.txt, sub1_in3.txt, sub1_in4.txt, sub1_in5.txt, sub2_in1.txt, sub3_in1.txt, sub3_in2.txt, sub4_in1.txt, sub4_in2.txt
Case Name Status Exec Time Memory
sub0_in1.txt AC 2 ms 896 KB
sub0_in2.txt AC 2 ms 896 KB
sub1_in1.txt AC 2 ms 896 KB
sub1_in2.txt AC 2 ms 896 KB
sub1_in3.txt AC 2 ms 896 KB
sub1_in4.txt AC 2 ms 896 KB
sub1_in5.txt AC 23 ms 13568 KB
sub2_in1.txt AC 10 ms 1664 KB
sub3_in1.txt AC 10 ms 1536 KB
sub3_in2.txt AC 9 ms 6784 KB
sub4_in1.txt WA 11 ms 2304 KB
sub4_in2.txt WA 7 ms 4480 KB