제출 #1310990

#제출 시각아이디문제언어결과실행 시간메모리
1310990_TemirhanDango Maker (JOI18_dango_maker)C++20
100 / 100
174 ms141816 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #if defined(__GNUC__) || defined(__clang__) #pragma GCC optimize("Ofast,unroll-loops,inline-functions,no-stack-protector,03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") #pragma clang loop vectorize(enable) #pragma clang loop interleave(enable) #endif // #define int long long #define sz(x) (int)x.size() #define F first #define S second #define pb push_back #define nl '\n' #define o_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef pair<int, int> pii; void file( string s = "" ) { if( s.empty() ) return; freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int N = 5e5 + 2; const int N1 = 1e6 + 2; const int inf = 1e9 + 2; const int INF = 1e18 + 2; const int mod = 1e9 + 7; int T = 1, n, m, dp[3003][3003][3], mx[6006]; bool ch[3003][3003], cv[3003][3003]; string s[3003]; void solve() { cin >>n >>m; s[0] = string(m + 2, '.'); for( int i = 1; i <= n; ++i ) { cin >>s[i]; s[i] = '.' + s[i] + '.'; } s[n + 1] = string(m + 2, '.'); for( int i = 1; i <= n; ++i ) for( int j = 1; j <= m; ++j ) { if( s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W' ) cv[i][j] = 1; if( s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W' ) ch[i][j] = 1; } for( int i = 1; i <= n; ++i ) for( int j = 1; j <= m; ++j ) { dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]}); if( ch[i][j] ) dp[i][j][1] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]) + 1; if( cv[i][j] ) dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][2]) + 1; mx[i + j] = max({mx[i + j], dp[i][j][0], dp[i][j][1], dp[i][j][2]}); } int ans = 0; for( int i = 1; i <= n + m; ++i ) ans += mx[i]; cout <<ans; } signed main() { file(""); ios_base::sync_with_stdio(false); cin.tie(nullptr); // cin >>T; while( T-- ) solve(); }

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

dango_maker.cpp:36:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   36 | const int INF = 1e18 + 2;
      |                 ~~~~~^~~
dango_maker.cpp: In function 'void file(std::string)':
dango_maker.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...