답안 #687634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687634 2023-01-26T17:24:11 Z speedyArda Red-blue table (IZhO19_stones) C++14
26 / 100
74 ms 1996 KB
#include "bits/stdc++.h"

using namespace std;

int main() 
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, m;
        cin >> n >> m;
        char ans[n+5][m+5];

        set<pair<int, int> > touse;
        int res = 0;
        if(n > m + 1 || (abs(n - m) <= 1 && n % 2))
        {
            for(int i = 1; i <= n; i++)
                for(int a = 1; a <= m; a++)
                    ans[i][a] = '+';
            res = n;
            for(int i = 1; i <= n; i++)
                touse.insert({0, i});
             for(int i = 1; i <= m; i++)
            {
                int curr = 0;
                bool valid = true;
                while(curr <= n / 2)
                {
                    pair<int, int> front = *(touse.begin());
                    if(front.first + 1 >= (m+1) / 2) {
                        valid = false;
                        break;
                    }
                    front.first++;
                    ans[front.second][i] = '-';
                    touse.erase(touse.begin());
                    touse.insert(front);
                    curr++;
                    //cout << curr << " " << front.first << " " << front.second << "\n";
                }
                if(!valid)
                    break;
                res++;
            }
        } else 
        {
            for(int i = 1; i <= n; i++)
                for(int a = 1; a <= m; a++)
                    ans[i][a] = '-';
            res = m;
            for(int i = 1; i <= m; i++)
                touse.insert({0, i});
            for(int i = 1; i <= n; i++)
            {
                int curr = 0;
                bool valid = true;
                while(curr <= m / 2)
                {
                    pair<int, int> front = *(touse.begin());
                    if(front.first + 1 >= (n+1) / 2) {
                        valid = false;
                        break;
                    }
                    front.first++;
                    ans[i][front.second] = '+';
                    touse.erase(touse.begin());
                    touse.insert(front);
                    curr++;
                    
                }
                if(!valid)
                    break;
                res++;
            }
        }

        cout << res << "\n";
        for(int i = 1; i <= n; i++) {
            for(int a = 1; a <= m; a++) {
                cout << ans[i][a];
            }
            cout << "\n";
        }
    }   
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong answer in test 2 1: 1 < 2
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Wrong answer in test 2 1: 1 < 2
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong answer in test 2 1: 1 < 2
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 1260 KB Output is correct
2 Correct 72 ms 1868 KB Output is correct
3 Correct 67 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1292 KB Output is correct
2 Correct 63 ms 1588 KB Output is correct
3 Correct 61 ms 1312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong answer in test 2 1: 1 < 2
3 Halted 0 ms 0 KB -