QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#122578#6644. Red Black Gridinstallb#WA 2ms3412kbC++141.9kb2023-07-10 19:30:352023-07-10 19:31:49

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-10 19:31:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3412kb
  • [2023-07-10 19:30:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int a[2005][2005];

void solve(){
    int n,k;
    vector <pair <int,pair <int,int> > > G;
    cin >> n >> k;
    // special judge for N=3
    if(n == 3){
        if(k == 3){
            cout << "BRB\n";
            cout << "BBB\n";
            cout << "BBB\n";
            return;
        }
        if(k == 5){
            cout << "BRB\n";
            cout << "BBB\n";
            cout << "BBR\n";
            return;
        }
        if(k == 7){
            cout << "BRB\n";
            cout << "BBB\n";
            cout << "RBR\n";
            return;
        }
        if(k == 9){
            cout << "BRB\n";
            cout << "RBR\n";
            cout << "BBB\n";
            return;
        }
    }
    for(int i = 1;i <= n;i ++){
        for(int j = (i & 1) ? 1 : 2;j <= n;j += 2){
            if(i == 1 || j == 1 || i == n || j == n){
                if((i == 1 && j == 1) || (i == n && j == n) || (i == 1 && j == n) || (i == n && j == 1)) G.push_back({2,{i,j}});
                else G.push_back({3,{i,j}});
            }
            else G.push_back({4,{i,j}});
        }
    }
    sort(G.begin(),G.end());
    reverse(G.begin(),G.end());
    for(int i = 1;i <= n;i ++){
        for(int j = 1;j <= n;j ++){
            a[i][j] = 0;
        }
    }
    for(auto [v,p] : G){
        auto [x,y] = p;
        if(k - v == 1 || k - v < 0) continue;
        k -= v; a[x][y] = 1;
    }
    if(k != 0){
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
    for(int i = 1;i <= n;i ++){
        for(int j = 1;j <= n;j ++){
            cout << (a[i][j] ? 'R' : 'B');
        }
        cout << '\n';
    }
}

int main(){
    ios::sync_with_stdio(false);
    int TC;
    cin >> TC;
    while(TC --){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3412kb

input:

2
3 6
3 1

output:

YES
BBB
BRB
BBR
NO

result:

wrong answer Condition failed: "A == B" (test case 1)