Submission #1054667

#TimeUsernameProblemLanguageResultExecution timeMemory
1054667ArthuroWichPaint By Numbers (IOI16_paint)C++17
32 / 100
1 ms604 KiB
#include "paint.h" #include<bits/stdc++.h> using namespace std; string solve_puzzle(string s, vector<int> c) { int n = s.length(); s = "@"+s; vector<int> pref(n+1, 0); for (int i = 1; i <= n; i++) { pref[i] = pref[i-1]; if (s[i] == '_') { pref[i]++; } } vector<pair<int, int>> segs(c.size()); int i = 1, j = 0; while(i <= n && j < c.size()) { if (s[i] != '_' && pref[i+c[j]-1]-pref[i-1] == 0) { segs[j].first = i-1; i += c[j]+1; j++; } else { i++; } } i = n, j = c.size()-1; while(i > 0 && j >= 0) { if (s[i] != '_' && pref[i-c[j]+1]-pref[i-c[j]] == 0) { segs[j].second = i-1; i -= c[j]+1; j--; } else { i--; } } string ans(n, '#'); for (int i = 0; i < c.size(); i++) { for (int j = segs[i].first; j <= segs[i].second; j++) { ans[j] = '?'; } if (segs[i].first+c[i]-1 >= segs[i].second-c[i]+1) { for (int j = segs[i].second-c[i]+1; j <= segs[i].first+c[i]-1; j++) { ans[j] = 'X'; } } } for (int i = 0; i < n; i++) { if (ans[i] == '#') { ans[i] = '_'; } if (s[i+1] == '_') { ans[i] = '_'; } } return ans; }

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     while(i <= n && j < c.size()) {
      |                     ~~^~~~~~~~~~
paint.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     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...