제출 #402731

#제출 시각아이디문제언어결과실행 시간메모리
402731cpp219Dango Maker (JOI18_dango_maker)C++14
0 / 100
1 ms332 KiB
#pragma GCC optimization "O2" #pragma GCC optimization "unroll-loop" #pragma GCC target ("avx2") #include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; const ll N = 3e3 + 6; const ll Log2 = 19; const ll inf = 1e9 + 7; typedef pair<ll,ll> LL; ///Road to EF/M char a[N][N]; ll n,m,ans; ll dx[3] = {0,1,0}; ll dy[3] = {0,0,1}; bool aval[N][N][5]; bool chk(ll x,ll y,ll dir){ ll A2 = x + dx[dir],B2 = y + dy[dir]; ll A1 = x - dx[dir],B1 = y - dy[dir]; return a[A1][B1] == 'R' && a[A2][B2] == 'W'; } ll dp[N][3],dia; ll f(ll row,ll prv){ if (row == dia) return 0; if (dp[row][prv] != -1) return dp[row][prv]; ll ans = f(row + 1,0); if (!prv){ if (aval[row][dia - row][1]) ans = max(ans,1 + f(row + 1,1)); if (aval[row][dia - row][2]) ans = max(ans,1 + f(row + 1,2)); } if (prv == 1){ if (aval[row][dia - row][2]) ans = max(ans,1 + f(row + 1,2)); } if (prv == 2){ if (aval[row][dia - row][1]) ans = max(ans,1 + f(row + 1,1)); } return dp[row][prv] = ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "tst" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); } cin>>n>>m; for (ll i = 1;i <= n;i++) for (ll j = 1;j <= m;j++) cin>>a[i][j]; for (ll i = 1;i <= n;i++) for (ll j = 1;j <= m;j++){ if (a[i][j] == 'G'){ aval[i][j][1] = chk(i,j,1); aval[i][j][2] = chk(i,j,2); } } //cout<<aval[3][2][2]; return 0; for (ll i = 2;i <= n + m;i++){ memset(dp,-1,sizeof(dp)); dia = i; ans += f(1,0); } cout<<ans; }

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

dango_maker.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization "O2"
      | 
dango_maker.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...