답안 #955637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955637 2024-03-31T07:52:47 Z n3rm1n Nautilus (BOI19_nautilus) C++17
0 / 100
1000 ms 604 KB
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long ll;

const int MAXN = 505, MAXCELL = 3e5+10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

}

int n, m, t;
int a[MAXN][MAXN];
string operations;
bitset < MAXCELL > fr;
void read()
{
    cin >> n >> m >> t;
    char s;
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = 1; j <= m; ++ j)
        {
            cin >> s;
            if(s == '#')
            {
                a[i][j] = 1;
            }
            else
            {
                fr[(i-1) * m + j] = 1;
               // cout << i << " " << j << " is coded as " << (i-1) * m + j << endl;
            }
        }
    }
    cin >> operations;
    //cout << fr.count() << endl;
}
bitset < MAXCELL > ans, last, newmove;

void go_south()
{
    newmove = (newmove | (last << m));
    newmove = (newmove & fr);

}

void go_north()
{
    newmove = (newmove | (last >> m));
    newmove = (newmove & fr);

}

void go_east()
{
    newmove = (newmove | (last << 1));
    newmove = (newmove & fr);

}

void go_west()
{
    newmove = (newmove | (last >> 1));
    newmove = (newmove & fr);

}
void solve_for(int start)
{
    last = (last ^ last);
    last[start] = 1;
    last = (last & fr);
    for (int i = 0; i < operations.size(); ++ i)
    {

        newmove = (newmove ^ newmove);
        if(operations[i] == '?' || operations[i] == 'N')go_north();
        if(operations[i] == '?' || operations[i] == 'S')go_south();
        if(operations[i] == '?' || operations[i] == 'E')go_east();
        if(operations[i] == '?' || operations[i] == 'W')go_west();
        last = newmove;
    }
    last = (last & fr);
    ans = (ans | last);

}
void solve()
{
    for (int start = 1; start <= n*m; ++ start)
    {
        solve_for(start);
    }
    cout << ans.count() << endl;
    /*for (int i = 1; i <= n; ++ i)
    {
        for (int j = 1; j <= m; ++ j)
            cout << ans[(i-1) * m + j] << " ";
        cout << endl;
    }*/
}
int main()
{

    speed();

    read();

    solve();
    return 0;
}

Compilation message

nautilus.cpp: In function 'void solve_for(int)':
nautilus.cpp:79:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for (int i = 0; i < operations.size(); ++ i)
      |                     ~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1064 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1064 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1064 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -