Submission #1035913

#TimeUsernameProblemLanguageResultExecution timeMemory
1035913baldwinhuang1Paint By Numbers (IOI16_paint)C++14
0 / 100
0 ms344 KiB
#include "paint.h" #include <cstdlib> #include <bits/stdc++.h> using namespace std; string solve_puzzle(string s, vector<int> c) { vector<int> start(c.size(), 0); for (int i = 1; i < c.size(); i++) { start[i] = start[i - 1] + 1 + c[i - 1]; } vector<int> end(c.size(), s.size() - 1); for (int i = c.size() - 2; i >= 0; i--) { end[i] = end[i + 1] - 1 - c[i + 1]; } string ans = s; for (int i = 0; i < c.size(); i++) { string a = s; string b = s; for (int j = start[i]; j <= (start[i] + c[i] - 1); j++) { a[j] = 'X'; } for (int j = end[i]; j >= (end[i] - c[i] + 1); j--) { b[j] = 'X'; } for (int j = start[i]; j < end[i]; j++) { if (a[j] == 'X' && b[j] == 'X') { ans[j] = 'X'; } else { ans[j] = '?'; } } // cout << start[i] << ' ' << end[i] << '\n'; // cout << a << '\n' << b << '\n'; } return ans; }

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 1; i < c.size(); i++) {
      |                     ~~^~~~~~~~~~
paint.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < c.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...