QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623085#5731. CheckerboardoschlimgenWA 0ms3528kbC++201.8kb2024-10-09 10:04:382024-10-09 10:04:38

Judging History

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

  • [2024-10-09 10:04:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2024-10-09 10:04:38]
  • 提交

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: ''