답안 #683311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683311 2023-01-18T07:11:45 Z FatihSolak Red-blue table (IZhO19_stones) C++17
0 / 100
70 ms 1420 KB

    #include <bits/stdc++.h>
    #define N 1005
    using namespace std;
    char ans[N][N];
    void solve(){
        int a,b;
        cin >> a >> b;
        if(a <= b){
            for(int i = 0;i<a;i++){
                for(int j = 0;j<b;j++){
                    ans[i][j] = '-';
                }
            }
            int num = a - (a/2 + 1);
            int res = b;
            set<pair<int,int>> s;
            for(int i = 0;i<a;i++){
                s.insert({-(b/2 + 1),i});
            }
            for(int i = 0;i<b && s.size();i++){
                vector<pair<int,int>> use;
                while(s.size() && use.size() < num){
                    use.push_back(*s.begin());
                    s.erase(s.begin());
                }
                for(auto u:use){
                    u.first++;
                    ans[u.second][i] = '+';
                    if(u.first)
                        s.insert(u);
                    else res++;
                }
            }
            cout << res << '\n';
            for(int i = 0;i<a;i++){
                for(int j = 0;j<b;j++){
                    cout << ans[i][j];
                }
                cout << '\n';
            }
        }
        else{
            for(int i = 0;i<a;i++){
                for(int j = 0;j<b;j++){
                    ans[i][j] = '+';
                }
            }
            int num = b - (b/2 + 1);
            int res = a;
            set<pair<int,int>> s;
            for(int i = 0;i<b;i++){
                s.insert({-(a/2 + 1),i});
            }
            for(int i = 0;i<a && s.size();i++){
                vector<pair<int,int>> use;
                while(s.size() && use.size() < num){
                    use.push_back(*s.begin());
                    s.erase(s.begin());
                }
                for(auto u:use){
                    u.first++;
                    ans[i][u.second] = '-';
                    if(u.first)
                        s.insert(u);
                    else res++;
                }
            }
            cout << res << '\n';
            for(int i = 0;i<a;i++){
                for(int j = 0;j<b;j++){
                    cout << ans[i][j];
                }
                cout << '\n';
            }
        }
    }
     
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        #ifdef Local
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
        int t=1;
        cin>>t;
        while(t--){
            solve();
        }
        #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
        #endif
    }

Compilation message

stones.cpp: In function 'void solve()':
stones.cpp:24:46: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |                 while(s.size() && use.size() < num){
      |                                   ~~~~~~~~~~~^~~~~
stones.cpp:58:46: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |                 while(s.size() && use.size() < num){
      |                                   ~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Wrong answer in test 3 3: 3 < 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Wrong answer in test 3 45: 45 < 46
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Wrong answer in test 3 3: 3 < 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 1380 KB Wrong answer in test 97 21: 97 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 1420 KB Wrong answer in test 24 24: 24 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Wrong answer in test 3 3: 3 < 4
2 Halted 0 ms 0 KB -