# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
395739 | CaroLinda | Red-blue table (IZhO19_stones) | C++14 | 73 ms | 1420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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())
const int LOG = 20 ;
const int MAXN=2e5+10 ;
using namespace std ;
int T , N , M , K ;
void solve()
{
scanf("%d %d", &N, &M ) ;
K = (N+2)>>1 ;
vector<int> freq(N,M) ;
vector< vector<char> > grid( N , vector<char>(M,'+') ) ;
int bestAns = N ;
int ans = N+1 , L = 0 , id = 0 ;
bool ok = true ;
for(int i = 0 ; i < M ; i++ , ans++ )
{
int cnt = K ;
while( cnt-- && ok )
{
if( id == N ) id = L ;
grid[id][i] = '-' ;
freq[id]-- ;
if( freq[id]*2 <= M )
{
for(int j = i+1 ; j < M ; j++ ) grid[id][j] = '-' ;
K-- ;
L++ ;
ans-- ;
}
id++ ;
}
bestAns = max(ans, bestAns ) ;
}
printf("%d\n" , bestAns ) ;
for(int i = 0 ; i < N ; i++ )
{
for(int j = 0 ; j < M ; j++ ) grid[i][j] = '+' ;
freq[i] = M ;
}
if(bestAns > N)
{
K = (N+2)>>1 ;
L = id = 0 ;
ans = N+1 ;
for(int i = 0 ; i < M ; i++ , ans++ )
{
int cnt = K ;
while( cnt-- )
{
if( id == N ) id = L ;
grid[id][i] = '-' ;
freq[id]-- ;
if( freq[id]*2 <= M )
{
for(int j = i+1 ; j < M ; j++ ) grid[id][j] = '-' ;
K-- ;
L++ ;
ans-- ;
}
id++ ;
}
if( ans == bestAns ) break ;
}
}
for(int i = 0 ; i < N ; i++ , printf("\n") )
for(int j = 0 ; j < M ; j++ ) printf("%c", grid[i][j] ) ;
}
int main()
{
scanf("%d", &T ) ;
while(T--) solve() ;
}
컴파일 시 표준 에러 (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... |