# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395791 | CaroLinda | Red-blue table (IZhO19_stones) | C++14 | 69 ms | 2220 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define sz(x) (int)(x.size())
using namespace std ;
int T , N , M , K ;
int teto(int num, int den) { return (num/den)+( num%den != 0 ) ; }
void solve()
{
scanf("%d %d", &N, &M ) ;
K = (N+2)>>1 ;
vector<int> freq(N,M) ;
vector< vector<char> > grid( N , vector<char>(M,'+') ) ;
for(int ans = 1 ; ans <= N+M ; ans++ )
for(int linhas_zoadas = max(0, ans-M) ; linhas_zoadas <= min(N, ans) ; linhas_zoadas++ )
{
int colunas_zoadas = ans-linhas_zoadas ;
int k_azul = K-linhas_zoadas ;
int k_verm = K-colunas_zoadas ;
int worst_line = (N-linhas_zoadas) ? teto( k_azul*(M-colunas_zoadas) , N-linhas_zoadas ) : 0 ;
if(worst_line*2 >= M) continue ;
for(int a = 0 ; a < linhas_zoadas ; a++ )
for(int b = 0 ; b < M ; b++ ) grid[a][b] = '-' ;
for(int a = colunas_zoadas , id = linhas_zoadas ; a < M ; a++ )
{
int cnt = k_azul ;
while(cnt--)
{
if(id == N) id = linhas_zoadas ;
grid[id][a] = '-' ;
id++ ;
}
}
printf("%d\n", N+M-ans) ;
for(int i = 0 ; i < N ; i++ , printf("\n"))
for(int j = 0 ; j < M ; j++ ) printf("%c", grid[i][j] ) ;
return ;
}
}
int main()
{
scanf("%d", &T ) ;
while(T--) solve() ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |