Submission #129942

# Submission time Handle Problem Language Result Execution time Memory
129942 2019-07-13T14:58:12 Z rajarshi_basu Nautilus (BOI19_nautilus) C++14
100 / 100
222 ms 760 KB
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <bitset>
#include <set>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define vv vector
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double> 
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>

using namespace std;

const int MAXN = 501;
const int MAXK = 60+10;

bitset<MAXN> tempgrid[MAXN];
bitset<MAXN> grid[MAXN];
bitset<MAXN> permgrid[MAXN];

void clearT(){
    FOR(i,MAXN)tempgrid[i].reset();
}

void imprint(){
    FOR(i,MAXN)grid[i] = grid[i] & permgrid[i];
}

void copyto(){
    FOR(i,MAXN)grid[i] = tempgrid[i];
}

void shiftleft(){
    FOR(i,MAXN)tempgrid[i] |= grid[i] << 1;
}
void shiftright(){
    FOR(i,MAXN)tempgrid[i] |= grid[i] >> 1;
}
void shiftup(){
    FOR(i,MAXN-1){
        tempgrid[i] |= grid[i+1];
    }
}
void shiftdown(){
    FOR(i,MAXN-1)tempgrid[i+1] |= grid[i];
}

int main(){
    int r,c,m;
    cin >> r >> c >> m;
    FOR(i,r)permgrid[i].reset();
    FOR(i,r){
        string s;
        cin >> s;
        FOR(j,c){
            if(s[j] == '.'){
                //cout << "hihih" << endl;
                permgrid[i][j] = 1;
            }
        }
    }
    string x;
    cin >> x;
    clearT();
    FOR(i,MAXN)grid[i].set();
    imprint();

    for(auto c : x){
        clearT();
        if(c == 'N'){
            shiftup();
        }else if(c == 'E'){
            shiftleft();
        }else if(c == 'W'){
            shiftright();
        }else if(c == 'S'){
            shiftdown();
        }else{
            shiftup();
            shiftdown();
            shiftleft();
            shiftright();
        }
        copyto();
        clearT();
        imprint();
    }
    int ctr = 0;
    FOR(i,MAXN){
        ctr += grid[i].count();
    }
    cout << ctr << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 7 ms 376 KB Output is correct
19 Correct 7 ms 376 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 7 ms 376 KB Output is correct
19 Correct 7 ms 376 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 7 ms 376 KB Output is correct
22 Correct 143 ms 712 KB Output is correct
23 Correct 141 ms 716 KB Output is correct
24 Correct 140 ms 632 KB Output is correct
25 Correct 139 ms 756 KB Output is correct
26 Correct 138 ms 760 KB Output is correct
27 Correct 183 ms 632 KB Output is correct
28 Correct 185 ms 712 KB Output is correct
29 Correct 184 ms 720 KB Output is correct
30 Correct 185 ms 760 KB Output is correct
31 Correct 181 ms 632 KB Output is correct
32 Correct 217 ms 632 KB Output is correct
33 Correct 221 ms 760 KB Output is correct
34 Correct 218 ms 632 KB Output is correct
35 Correct 216 ms 640 KB Output is correct
36 Correct 222 ms 760 KB Output is correct