제출 #377656

#제출 시각아이디문제언어결과실행 시간메모리
377656cpp219Nautilus (BOI19_nautilus)C++14
100 / 100
330 ms179308 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 500 + 9; const ll inf = 1e16 + 7; char a[N][N]; ll n,m,sz; string s; bitset<520> dp[N][5200],sea[N],x; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "test" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>m>>sz; for (ll i = 1;i <= n;i++) for (ll j = 1;j <= m;j++){ cin>>a[i][j]; if (a[i][j] == '.') sea[i][j] = dp[i][0][j] = 1; else sea[i][j] = dp[i][0][j] = 0; } cin>>s; s = " " + s; for (ll t = 1;t <= sz;t++){ for (ll i = 1;i <= n;i++){ if (s[t] == 'N') dp[i][t] = (dp[i + 1][t - 1]); if (s[t] == 'S') dp[i][t] = (dp[i - 1][t - 1]); if (s[t] == 'E') dp[i][t] = ((dp[i][t - 1] << 1)); if (s[t] == 'W') dp[i][t] = ((dp[i][t - 1] >> 1)); if (s[t] == '?') dp[i][t] = ((dp[i][t - 1] << 1)|(dp[i][t - 1] >> 1)|(dp[i + 1][t - 1])|(dp[i - 1][t - 1])); dp[i][t] &= sea[i]; dp[i][t] &= sea[i]; //for (ll j = 1;j <= m;j++) cout<<dp[i][t][j]; exit(0); } } ll ans = 0; for (ll i = 1;i <= n;i++){ for (ll j = 1;j <= m;j++){ if (dp[i][sz][j]) ans++; //cout<<dp[i][sz][j]; } //cout<<"\n"; } cout<<ans; }

컴파일 시 표준 에러 (stderr) 메시지

nautilus.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
nautilus.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
nautilus.cpp: In function 'int main()':
nautilus.cpp:42:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   42 |             if (s[t] == '?')
      |             ^~
nautilus.cpp:44:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   44 |                 dp[i][t] &= sea[i]; dp[i][t] &= sea[i];
      |                 ^~
nautilus.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...