Submission #781382

# Submission time Handle Problem Language Result Execution time Memory
781382 2023-07-13T05:04:56 Z ZHIRDILBILDIZ Red-blue table (IZhO19_stones) C++14
0 / 100
41 ms 340 KB
#include<bits/stdc++.h>
using namespace std ;
int func()
{
}
int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    int t ;
    cin >> t ;
    while(t--)
    {
        int n, m, mx = 0 ;
        cin >> n >> m ;
        char c[n][m], ans[n][m] ;
        if(n * m <= 16)
        {
            for(int x = 0 ; x < (1 << (n * m)) ; x++)
            {
                int st[m] = {}, str[n] = {}, sum = 0 ;
                for(int i = 0 ; i < n ; i++)
                    for(int j = 0 ; j < m ; j++)
                        if(x & (1 << (i * m + j)))
                        {
                            str[i]++ ;
                            c[i][j] = '+' ;
                        }
                        else
                        {
                            st[j]++ ;
                            c[i][j] = '-' ;
                        }
                for(int i = 0 ; i < n ; i++)
                    if(str[i] > m / 2)sum++ ;
                for(int i = 0 ; i < m ; i++)
                    if(st[i] > n / 2)sum++ ;
                if(mx < sum)
                {
                    for(int i = 0 ; i < n ; i++)
                        for(int j = 0 ; j < m ; j++)
                            ans[i][j] = c[i][j] ;
                }
                mx = max(mx, sum) ;
            }
            cout << mx << '\n' ;
            for(int i = 0 ; i < n ; i++)
            {
                for(int j = 0 ; j < m ; j++)
                    cout << ans[i][j] ;
                cout << '\n' ;
            }
        }
        if(n % 2 && m % 2)
        {
        }
        if(min(n, m) == 3)
        {
            if(n == 3)
            {
                for(int i = 0 ; i < n - 1 ; i++)
                    for(int j = 0 ; j < m ; j++)
                        ans[i][j] = '-' ;
                for(int i = 0 ; i < m ; i++)
                    ans[n - 1][i] = '+' ;
            }
            else
            {
                for(int i = 0 ; i < n ; i++)
                    for(int j = 0 ; j < m - 1 ; j++)
                        ans[i][j] = '+' ;
                for(int i = 0 ; i < n ; i++)
                    ans[i][m - 1] = '-' ;
            }
            cout << max(n, m) + 1 << '\n' ;
            for(int i = 0 ; i < n ; i++)
            {
                for(int j = 0 ; j < m ; j++)
                    cout << ans[i][j] ;
                cout << '\n' ;
            }
        }
    }
    return 0 ;
}

Compilation message

stones.cpp: In function 'int func()':
stones.cpp:5:1: warning: no return statement in function returning non-void [-Wreturn-type]
    5 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Extra information in the output file
2 Halted 0 ms 0 KB -