제출 #1010928

#제출 시각아이디문제언어결과실행 시간메모리
1010928c2zi6Paint By Numbers (IOI16_paint)C++14
0 / 100
0 ms600 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "paint.h" bool azat(string& s, int l, int r) { if (r >= s.size()) return false; if (l < 0) return false; replr(i, l, r) if (s[i] == '_') return false; return true; } /*VI apply(string s, VI c, bool rv = false) {*/ /* if (rv) {*/ /* reverse(all(s));*/ /* reverse(all(c));*/ /* }*/ /* VI ret;*/ /* int p = 0;*/ /* for (int i = 0; i < s.size(); i++) {*/ /* int l = i;*/ /* int r = i+c[p]-1;*/ /* if (azat(s, l, r)) {*/ /* if (rv) ret.pb(s.size()-i-c[p]);*/ /* else ret.pb(i);*/ /* i += c[p];*/ /* if (++p == c.size()) break;*/ /* }*/ /* }*/ /* if (rv) reverse(all(ret));*/ /* return ret;*/ /*}*/ VI apply(string s, VI c, bool rv = false) { if (rv) { reverse(all(s)); reverse(all(c)); } int n = s.size(); int k = c.size(); VVI dp(n+1, VI(k+1)); replr(i, 0, n) dp[i][0] = true; replr(i, 1, n) { replr(p, 1, k) { int l = c[p-1]; if (azat(s, i-l, i-1) && (i-l-1 < 0 || s[i-l-1] != 'X')); else continue; if (p-1 == 0 && i-l-1 == -1) dp[i][p] = true; else { replr(j, 0, i-l-1) if (dp[j][p-1]) dp[i][p] = true; } } } /*replr(p, 1, k) {*/ /* replr(i, 1, n) cout << dp[i][p];*/ /* cout << endl;*/ /*}*/ VI ret; int p = k; reprl(i, n, 1) { if (s[i-1] == 'X' || i-1 == 0) { replr(l, i, n) if (dp[l][p]) { if (rv) ret.pb(n - l); else ret.pb(l - c[p-1]); i = l - c[p-1]; p--; break; } } } if (!rv) reverse(all(ret)); return ret; } string solve_puzzle(string s, VI c) { int n = s.size(); int k = c.size(); VI L = apply(s, c); VI R = apply(s, c, true); for (int x : L) cout << x+1 << " "; cout << endl; for (int x : R) cout << x+1 << " "; cout << endl; string ans(n, '_'); rep(i, k) { replr(j, L[i], R[i]) { if (azat(s, j, j+c[i]-1)) { replr(l, j, j+c[i]-1) ans[l] = '?'; } } replr(j, R[i], L[i]+c[i]-1) ans[j] = 'X'; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'bool azat(std::string&, int, int)':
paint.cpp:35:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if (r >= s.size()) return false;
      |         ~~^~~~~~~~~~~
paint.cpp: In function 'std::string solve_puzzle(std::string, VI)':
paint.cpp:107:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  107 |     for (int x : L) cout << x+1 << " "; cout << endl;
      |     ^~~
paint.cpp:107:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  107 |     for (int x : L) cout << x+1 << " "; cout << endl;
      |                                         ^~~~
paint.cpp:108:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  108 |     for (int x : R) cout << x+1 << " "; cout << endl;
      |     ^~~
paint.cpp:108:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  108 |     for (int x : R) cout << x+1 << " "; cout << endl;
      |                                         ^~~~
#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...