답안 #424805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
424805 2021-06-12T10:26:52 Z egekabas Red-blue table (IZhO19_stones) C++14
0 / 100
166 ms 1304 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, m, rev;
int cur[1009];
void solve(){
    cin >> n >> m;
    
    pii use = {-1, -1};
    for(int i = 0; i <= n; ++i){
        int curans = i;
        int needother = max(0, (n+2)/2-(n-i));
        int extra = m-(m+2)/2;
        if(needother == 0)
            curans += m;
        else{
            curans += min(m, i*extra/needother);
        }
        use = max(use, {curans, i});    
        //cout << i << ' ' <<  << '\n';
    }
    for(int j = 0; j < m; ++j)
        cur[j] = 0;
    cout << use.ff << '\n';
    int left = use.ss;
    int need = max(0, (n+2)/2-(n-left));
    int col = m;
    if(need)
        int col = min(m, left*(m-(m+2)/2)/need);
    for(int i = 0; i < n; ++i){
        if(left){
            --left;
            int extra = m-(m+2)/2;
            set<pii> s;
            for(int j = 0; j < col; ++j){
                s.insert({cur[j], j});
            }
            set<int> use;
            while(extra--){
                if(s.size()){
                    use.insert(s.begin()->ss);
                    s.erase(s.begin());
                }
            }
            for(int j = 0; j < m; ++j){
                if(use.size() && j == *use.begin()){
                    ++cur[j];
                    use.erase(use.begin());
                    cout << '-';
                }
                else
                    cout << '+';
            }
        }
        else
            for(int j = 0; j < m; ++j)
                cout << '-';
        cout << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    int t;
    cin >> t;
    while(t--)
        solve();
    
}

Compilation message

stones.cpp: In function 'void solve()':
stones.cpp:40:13: warning: unused variable 'col' [-Wunused-variable]
   40 |         int col = min(m, left*(m-(m+2)/2)/need);
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 154 ms 1236 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 166 ms 1304 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -