QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#623085 | #5731. Checkerboard | oschlimgen | WA | 0ms | 3528kb | C++20 | 1.8kb | 2024-10-09 10:04:38 | 2024-10-09 10:04:38 |
Judging History
answer
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <fstream>
class inputParams {
public:
int rows;
int cols;
int wideRows;
int wideCols;
std::vector<int> rowSizes;
std::vector<int> colSizes;
inputParams(const std::string& pathToFile) {
read(pathToFile);
}
void read(const std::string& pathToFile) {
std::ifstream in(pathToFile);
if(in.is_open()) {
std::string line;
std::getline(in, line);
rows = line[0] - '0';
cols = line[2] - '0';
wideRows = line[4] - '0';
wideCols = line[6] - '0';
for(int i = 0; i < wideRows; ++i) {
std::getline(in, line);
rowSizes.push_back(line[0] - '0');
}
for(int i = 0; i < wideCols; ++i) {
std::getline(in, line);
colSizes.push_back(line[0] - '0');
}
in.close();
}
}
};
std::string printChecker(const std::vector<int>& rows, const std::vector<int>& cols) {
bool rowStartColor = true;
bool checkerColor = true;
std::string output;
for(int ri = 0; ri < rows.size(); ++ri) {
for(int rj = 0; rj < rows[ri]; ++rj) {
std::string line;
checkerColor = rowStartColor;
for(int ci = 0; ci < cols.size(); ++ci) {
for(int cj = 0; cj < cols[ci]; ++cj) {
if(checkerColor) {
line += "B";
} else {
line += "W";
}
}
checkerColor = !checkerColor;
}
output += line + "\n";
}
rowStartColor = !rowStartColor;
}
return output;
}
int main() {
inputParams input("input.txt");
std::string output;
output = printChecker(input.rowSizes, input.colSizes);
std::cout << output;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
6 5 3 2 1 2 3 3 2
output:
result:
wrong answer 1st lines differ - expected: 'BBBWW', found: ''