Submission #341833

# Submission time Handle Problem Language Result Execution time Memory
341833 2020-12-31T07:05:47 Z Redhood Red-blue table (IZhO19_stones) C++14
0 / 100
8 ms 1388 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define len(x) (int)(x).size()
#define pb push_back
#define p2(x) (x)*(x)
#define all(x) (x).begin() , (x).end()
#define mkp make_pair


//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("-O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long double ld;
typedef long long ll;


void solve(int n , int m){
    /// red okay???
    /// lulz

    pair < int , int > best = {-1 , -1};
    int ans = 0;
    for(int A = 0; A <= n; ++A){
        /// lulz
        int ost = m - (m + 2)/2;
        int need = max(0 , (n+2)/2 - (n-A));
        int B;
        if(need == 0){
            B = m;
            if(ans < A + B)
            ans = A + B , best = {A , B};
        }else{
            B = (A * ost) / need;
            B = min(B , m);
            if(ans < A + B)
            ans = A + B , best = {A , B};
        }
    }
    /// lulz
    cout << ans << '\n';

    int A = best.fi , B = best.se;
    int ost = m - (m + 2)/2;
    int need = max(0 , (n+2)/2 - (n-A));
    if(need == 0){
        for(int i = 0 ; i < n; ++i){
            if(A){
                for(int j = 0 ; j < (m+2)/2;++j)
                    cout << '+';
                for(int j = (m+2)/2; j < m; ++j)
                    cout << '-';
                A--;
            }else{
                for(int j = 0 ; j < m; ++j)
                    cout << '-';
            }
            cout << '\n';
        }
    }else{
//        system("pause");
//        cout << " YO " << n << ' '<< m << '\n';
//        cout << "YO\n";
//        cout << A << ' ' << B << '\n';
//        cout << ost << ' ' << need << '\n';
        deque < int > bad;
        for(int j = 0 ; j < B; ++j)
            bad.pb(j);
        vector < int > val(m);

        for(int i = 0 ; i < n; ++i){
            if(A){
                /// poses
                string cur = string(m , '+');



                for(int j = 0; j < m - (m + 2) / 2;  ++j){
                    /// lulz

                    int X = len(bad);
                    while(bad.empty() && X){
                        --X;
                        int head = bad.front();bad.pop_front();
                        if(val[head] == need)
                            continue;
                        cur[head] = '+';
                        val[head]++;
                        bad.pb(head);
                    }
                }


                cout << cur;
                A--;
            }else{
                for(int j = 0 ; j < m; ++j)
                    cout << '-';
            }
            cout << '\n';
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int t;
    cin >> t;

//    for(int i = 1; i<=10; ++i)
//        for(int j = 1; j <= 10; ++j)
//            solve(i , j);
    while(t--){
        int n ,m ;
    cin >> n >> m;
        solve( n , m);
    }
}
/*


*/

Compilation message

stones.cpp: In function 'void solve(int, int)':
stones.cpp:46:9: warning: unused variable 'ost' [-Wunused-variable]
   46 |     int ost = m - (m + 2)/2;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1388 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1388 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB in the table A+B is not equal to 5