Submission #955637

#TimeUsernameProblemLanguageResultExecution timeMemory
955637n3rm1nNautilus (BOI19_nautilus)C++17
0 / 100
1064 ms604 KiB
#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 (stderr)

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)
      |                     ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...