# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
884498 | 2023-12-07T14:03:16 Z | ReLice | Dango Maker (JOI18_dango_maker) | C++14 | 304 ms | 111076 KB |
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define bc back() #define arr array using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <class _T> bool chmin(_T &x, const _T &y){ bool flag=false; if(x>y){ x=y;flag|=true; } return flag; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag=false; if (x<y){ x=y;flag|=true; } return flag; } #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e9+7; const ll mod=1e9+7; const ll N=3e3+7; const ld eps=1e-9; char a[N][N]; bool ver(ll x,ll y){ return (a[x-1][y]=='R' && a[x][y]=='G' && a[x+1][y]=='W'); } bool hor(ll x,ll y){ return (a[x][y-1]=='R' && a[x][y]=='G' && a[x][y+1]=='W'); } void solve(){ ll i,j; ll n,m; cin>>n>>m; vector<vector<ll> > dio(n+m+5); for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ cin>>a[i][j]; dio[i+j].pb(i); } } ll ans=0; for(i=2;i<=n+m;i++){ ll k=dio[i].sz; vector<arr<ll,3> > dp(k+5); for(j=1;j<=k;j++){ ll x=dio[i][j-1],y=i-x; dp[j][0]=max({dp[j-1][0],dp[j-1][1],dp[j-1][2]}); if(ver(x,y)) dp[j][1]=max({dp[j-1][0],dp[j-1][1]})+1; if(hor(x,y)) dp[j][2]=max({dp[j-1][0],dp[j-1][2]})+1; } ans+=max({dp[k][0],dp[k][1],dp[k][2]}); } cout<<ans<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 600 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 472 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 344 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 0 ms | 600 KB | Output is correct |
41 | Correct | 0 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 464 KB | Output is correct |
49 | Correct | 1 ms | 600 KB | Output is correct |
50 | Correct | 1 ms | 344 KB | Output is correct |
51 | Correct | 1 ms | 600 KB | Output is correct |
52 | Correct | 0 ms | 348 KB | Output is correct |
53 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 600 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 472 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 344 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 0 ms | 600 KB | Output is correct |
41 | Correct | 0 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 464 KB | Output is correct |
49 | Correct | 1 ms | 600 KB | Output is correct |
50 | Correct | 1 ms | 344 KB | Output is correct |
51 | Correct | 1 ms | 600 KB | Output is correct |
52 | Correct | 0 ms | 348 KB | Output is correct |
53 | Correct | 0 ms | 348 KB | Output is correct |
54 | Correct | 1 ms | 856 KB | Output is correct |
55 | Correct | 2 ms | 9468 KB | Output is correct |
56 | Correct | 1 ms | 856 KB | Output is correct |
57 | Correct | 3 ms | 7004 KB | Output is correct |
58 | Correct | 27 ms | 16216 KB | Output is correct |
59 | Correct | 304 ms | 110868 KB | Output is correct |
60 | Correct | 289 ms | 111076 KB | Output is correct |
61 | Correct | 285 ms | 110820 KB | Output is correct |
62 | Correct | 1 ms | 604 KB | Output is correct |
63 | Correct | 287 ms | 107588 KB | Output is correct |
64 | Correct | 267 ms | 110988 KB | Output is correct |
65 | Correct | 251 ms | 110768 KB | Output is correct |
66 | Correct | 272 ms | 110872 KB | Output is correct |
67 | Correct | 262 ms | 110676 KB | Output is correct |
68 | Correct | 252 ms | 110672 KB | Output is correct |
69 | Correct | 271 ms | 110840 KB | Output is correct |
70 | Correct | 23 ms | 16368 KB | Output is correct |
71 | Correct | 22 ms | 16212 KB | Output is correct |
72 | Correct | 25 ms | 16220 KB | Output is correct |
73 | Correct | 23 ms | 16220 KB | Output is correct |
74 | Correct | 22 ms | 16412 KB | Output is correct |
75 | Correct | 23 ms | 16220 KB | Output is correct |
76 | Correct | 23 ms | 16308 KB | Output is correct |
77 | Correct | 25 ms | 16296 KB | Output is correct |
78 | Correct | 31 ms | 16284 KB | Output is correct |
79 | Correct | 23 ms | 16220 KB | Output is correct |
80 | Correct | 24 ms | 16200 KB | Output is correct |
81 | Correct | 29 ms | 16220 KB | Output is correct |
82 | Correct | 23 ms | 16164 KB | Output is correct |
83 | Correct | 22 ms | 16220 KB | Output is correct |
84 | Correct | 24 ms | 16220 KB | Output is correct |
85 | Correct | 23 ms | 16216 KB | Output is correct |
86 | Correct | 23 ms | 16216 KB | Output is correct |
87 | Correct | 31 ms | 16516 KB | Output is correct |
88 | Correct | 23 ms | 16220 KB | Output is correct |
89 | Correct | 22 ms | 16212 KB | Output is correct |
90 | Correct | 22 ms | 16232 KB | Output is correct |