Submission #216076

# Submission time Handle Problem Language Result Execution time Memory
216076 2020-03-26T17:20:24 Z MKopchev Nautilus (BOI19_nautilus) C++14
100 / 100
359 ms 760 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=500+5;
int n,m,k;

bitset<nmax> can[nmax],current[nmax],help[nmax],idle;

int main()
{
    scanf("%i%i%i",&n,&m,&k);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            char c=getchar();
            while(c!='.'&&c!='#')c=getchar();
            if(c=='.')can[i][j]=1;
        }

    for(int i=1;i<=n;i++)
        current[i]=can[i];

    for(int i=1;i<=k;i++)
    {
        char c=getchar();
        while(c!='W'&&c!='E'&&c!='S'&&c!='N'&&c!='?')c=getchar();

        for(int p=1;p<=n;p++)
            help[p]=idle;

        if(c=='N'||c=='?')
        {
            for(int p=1;p<=n;p++)
                help[p]=help[p]|current[p+1];
        }
        if(c=='S'||c=='?')
        {
            for(int p=1;p<=n;p++)
                help[p]=help[p]|current[p-1];
        }

        if(c=='E'||c=='?')
        {
            for(int p=1;p<=n;p++)
                help[p]=help[p]|(current[p]<<1);
        }

        if(c=='W'||c=='?')
        {
            for(int p=1;p<=n;p++)
                help[p]=help[p]|(current[p]>>1);

        }
        for(int p=1;p<=n;p++)
            current[p]=help[p]&can[p];

        /*
        int output=0;
            for(int p=1;p<=n;p++)
        output=output+current[p].count();

        printf("%i\n",output);

        cout<<"current "<<endl;
        for(int p=1;p<=n;p++)
        {
            for(int q=1;q<=m;q++)cout<<current[p][q]<<" ";
            cout<<endl;
        }

        cout<<"help "<<endl;
        for(int p=1;p<=n;p++)
        {
            for(int q=1;q<=m;q++)cout<<help[p][q]<<" ";
            cout<<endl;
        }
        cout<<"---"<<endl;
        */
    }

    int output=0;
        for(int p=1;p<=n;p++)
    output=output+current[p].count();

    printf("%i\n",output);
    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 408 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 408 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 156 ms 640 KB Output is correct
23 Correct 155 ms 700 KB Output is correct
24 Correct 156 ms 640 KB Output is correct
25 Correct 152 ms 704 KB Output is correct
26 Correct 156 ms 680 KB Output is correct
27 Correct 219 ms 640 KB Output is correct
28 Correct 224 ms 712 KB Output is correct
29 Correct 225 ms 704 KB Output is correct
30 Correct 225 ms 712 KB Output is correct
31 Correct 253 ms 684 KB Output is correct
32 Correct 275 ms 708 KB Output is correct
33 Correct 273 ms 640 KB Output is correct
34 Correct 275 ms 700 KB Output is correct
35 Correct 359 ms 712 KB Output is correct
36 Correct 269 ms 760 KB Output is correct