제출 #131679

#제출 시각아이디문제언어결과실행 시간메모리
131679youssefbou62Nautilus (BOI19_nautilus)C++14
66 / 100
1073 ms2808 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize ("O3") #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define ll long long #define ull unsigned long long #define pb push_back #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL) typedef pair<int, int> pi; typedef pair<ll,ll> pll; typedef pair<int,pi> trp ; typedef vector<pi> vpi; typedef vector<pll> vpll ; // int ab (int x ) { return (x>0?x:-x); } const int N = 505 , M = 5005 ; int R , C , dp[2][N][N]; string seq ; char a[N][N] ; void direction(int& i, int& j , char c ){ if( c =='N'){ i-- ; }else if( c =='S'){ i++; }else if( c =='E'){ j++ ; }else if( c =='W'){ j--; } } bool valid (int i , int j ){ return ( i >= 0 && j >= 0 && i < R && j < C && a[i][j]!='#') ; } int main(){ int m ; scanf("%d%d%d\n",&R,&C,&m); for(int i = 0 ; i < R ; i++ ){ for(int j = 0 ; j < C ; j++ ){ scanf(" %c",a[i]+j) ; } } cin >> seq ; for(int i = 0 ; i < R ; i++ ){ for(int j = 0 ; j < C ;j++) dp[0][i][j] = 1 ; } // memset(dp[0],1,sizeof dp[0]); string dir = "NSWE"; for(int moves = 0 ; moves < m ; moves++ ){ for(int i = 0 ; i < R ; i++ ){ for(int j = 0 ; j < C ; j++ ){ int y= j , x = i ; if( a[i][j] == '#')continue ; for(char c : dir ){ if( seq[moves] == '?' || c==seq[moves] ){ direction(x,y,c); if( valid ( x , y ) ){ dp[1][x][y] |= dp[0][i][j]; } x = i ; y = j ; } } } } for(int i = 0 ; i < R ; i++ ){ for(int j = 0 ; j < C ; j++ ){ dp[0][i][j] =dp[1][i][j]; dp[1][i][j] =0 ; } } } // for(int mm =0 ; mm < m ; mm++ ){ // cout << mm << endl; // for(int i = 0 ; i < R ; i++ ){ // for(int j = 0 ; j < C ; j++ )cout << dp[m][i][j]<< " "; // cout << endl; // } // cout << endl; // } int ans = 0 ; for(int i = 0 ; i < R ; i++ )for(int j = 0 ; j < C ; j++ )ans += dp[0][i][j] ; cout << ans << endl; }

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

nautilus.cpp: In function 'int main()':
nautilus.cpp:46:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d%d%d\n",&R,&C,&m); 
 ~~~~~^~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c",a[i]+j) ; 
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...