Submission #496276

#TimeUsernameProblemLanguageResultExecution timeMemory
496276kinglineNautilus (BOI19_nautilus)C++17
29 / 100
3 ms332 KiB
/*#pragma GCC optimize("O3") #pragma GCC target ("avx2") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops")*/ #include <bits/stdc++.h> #define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout); #define pb push_back #define all(data) data.begin(), data.end() #define endl '\n' #define ll long long //#define int long long #define pii pair < int, int > using namespace std; const int N = 2e5 + 5; int n, m, k, use, used[505][505]; char c[505][505]; bool can[505][505]; string s; void check(int x, int y) { bool ok = 1; for(int i = 0; i < s.size(); i++) { bool cn = 0; if(s[i] == 'S' && x + 1 <= n && c[x + 1][y] == '.') { x++; cn = 1; } if(s[i] == 'N' && x - 1 > 0 && c[x - 1][y] == '.') { x--; cn = 1; } if(s[i] == 'W' && y - 1 > 0 && c[x][y - 1] == '.') { y--; cn = 1; } if(s[i] == 'E' && y + 1 > 0 && c[x][y + 1] == '.') { y++; cn = 1; } if(!cn) { ok = 0; break; } } if(ok) can[x][y] = 1; } main() { //file("pieaters"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> c[i][j]; } } cin >> s; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(c[i][j] == '.') { check(i, j); } } } int ans = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(can[i][j]) { ans++; } } } cout << ans; }

Compilation message (stderr)

nautilus.cpp: In function 'void check(int, int)':
nautilus.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
nautilus.cpp: At global scope:
nautilus.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...