Is there any chance that a Codeforces compiler gave a wrong output, Although the code is correct.

Revision en1, by parth_2003, 2024-06-14 21:14:32

So I was solving Question Chess Tournament 1569B rated 1000. when I submit the code then the output on the given test cases are showing wrong, Although I checked them on my compiler, and the code was working fine. Here is the code,

include<bits/stdc++.h>

using namespace std;

int main(){ int t; cin >> t; while(t--){ int n; cin >> n; vector v(n); int countO=0; int countT=0; for(int i=0; i<n; i++){ cin >> v[i]; if(v[i] == 1){ countO++; } else{ countT++; } } if(countT == 2 || countT == 1){ cout << "NO" << endl; continue; }

vector<vector<char> > f(n, vector<char>(n, '='));
for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
       if(i == j){
         f[i][j] = 'X';
       }
       else if(v[i] == 1 && v[j] == 2){
         f[i][j] = '+';
       }
       else if(v[i] == 1 && v[j] == 1){
         f[i][j] = '=';
       }
    }   
}

vector<int> type2;
for(int i=0; i<n; i++){
    if(v[i] == 2){
       type2.push_back(i);
    }
}
for(int i=0; i<type2.size(); i++){
    int curr = type2[i];
    int next = type2[i+1 % (type2.size())];
    f[curr][next] = '+';
    f[next][curr] = '-';
}

cout << "YES" << endl;  
for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
       cout << f[i][j];  
    }
    cout << endl;
}

} }

Tags need help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English parth_2003 2024-06-14 21:14:32 1367 Initial revision (published)