답안 #258888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258888 2020-08-06T16:59:53 Z uacoder123 Red-blue table (IZhO19_stones) C++14
100 / 100
102 ms 2296 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
char arr[1000][1000];
int main()
{
    int test;
    cin>>test;
    for(;test>0;--test)
    {
        int n,m;
        cin>>n>>m;
        int nr=(m)/2+1;
        int nc=(n)/2+1;
        iii ans=mp(m,mp(0,m));
        for(int i=0;i<=m;++i)
        {
            for(int j=0;j<=n;++j)
            {
                int c=nr-(m-i);
                if(c>0)
                {
                    c=int((c*j)/i)+min((c*j)%i,1);
                    if(c<=n-nc)
                        ans=max(ans,mp(i+j,mp(j,i)));
                }
                else
                    ans=max(ans,mp(i+j,mp(j,i)));
            }
        }
        for(int i=0;i<n;++i)
        {
            for(int j=0;j<m;++j)
            {
                if(j<ans.S.S)
                    arr[i][j]='-';
                else
                    arr[i][j]='+';
            }
        }
        int c=0;
        for(int i=0;i<ans.S.F;++i)
        {
            int co=0,t=nr-(m-ans.S.S);
            while(co!=t)
            {
                arr[i][c]='+';
                c=(c+1)%ans.S.S;
                co++;
            }
        }
        cout<<ans.F<<endl;
        for(int i=0;i<n;++i)
        {
            for(int j=0;j<m;++j)
                cout<<arr[i][j];
            cout<<endl;
        }
    }
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 16 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 1400 KB Output is correct
2 Correct 52 ms 1912 KB Output is correct
3 Correct 47 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 1400 KB Output is correct
2 Correct 39 ms 1880 KB Output is correct
3 Correct 36 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 16 ms 384 KB Output is correct
5 Correct 102 ms 1400 KB Output is correct
6 Correct 52 ms 1912 KB Output is correct
7 Correct 47 ms 2168 KB Output is correct
8 Correct 74 ms 1400 KB Output is correct
9 Correct 39 ms 1880 KB Output is correct
10 Correct 36 ms 1656 KB Output is correct
11 Correct 41 ms 640 KB Output is correct
12 Correct 41 ms 1912 KB Output is correct
13 Correct 41 ms 2040 KB Output is correct
14 Correct 32 ms 1664 KB Output is correct
15 Correct 47 ms 2296 KB Output is correct
16 Correct 35 ms 1912 KB Output is correct
17 Correct 16 ms 1280 KB Output is correct