제출 #1230737

#제출 시각아이디문제언어결과실행 시간메모리
1230737naelwbRed-blue table (IZhO19_stones)C++20
27 / 100
27 ms1604 KiB
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast") #define fi first #define se second #define pb push_back #define int long long #define mp make_pair #define pii pair<int, int> #define ti3 tuple<int,int,int> typedef long long ll; const int INF = 1e13; const int mxn = 2e5+5; const int mod = 1e9+7; inline int mul(int a, int b){return (a*b)%mod;} inline int tot(int a, int b){return (a+b)%mod;} void chmx(int &a, int b){a = max(a, b);} void solve(){ int n, m; cin >> n >> m; int dp[2][n+1][m+1]; for(int i = 0; i < 2; i++){ for(int j = 0; j <= n; j++){ for(int k = 0; k <= m; k++)dp[i][j][k] = 0; } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ dp[0][i][j] = max(dp[0][i-1][j],dp[1][i-1][j]); dp[1][i][j] = max(dp[1][i][j-1],dp[0][i][j-1]); if(j>=m/2+1){ dp[0][i][j] += 1; } if(i>=n/2+1){ dp[1][i][j] += 1; } } } cout << max(dp[0][n][m],dp[1][n][m]) << endl; // cout << dp[0][n-1][m] << ' ' << dp[1][n][m-1] << endl; if(max(dp[0][n-1][m],dp[1][n][m-1])==dp[0][n-1][m]){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(j<=m/2+1){ cout << '+'; }else cout << '-'; }cout<<endl; } } else{ for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(i<=n/2+1){ cout<<'-'; }else cout << '+'; }cout<<endl; } } } int32_t main(){ fastio; int t = 1; cin>>t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...