제출 #288479

#제출 시각아이디문제언어결과실행 시간메모리
288479TangentPaint By Numbers (IOI16_paint)C++17
32 / 100
1 ms256 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order(), order_of_key() typedef long long ll; typedef long double dd; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<dd, dd> pdd; typedef vector<int> vii; typedef vector<ll> vll; typedef vector<dd> vdd; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<pdd> vpdd; typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<vdd> vvdd; typedef vector<vpii> vvpii; typedef vector<vpll> vvpll; typedef vector<vpdd> vvpdd; typedef vector<bool> vb; const int inf = 1 << 30; #define rep(i, n) for (ll i = 0; i < n; i++) #define ffor(i, a, b) for(ll i = a; i < b; i++) #define forin(x, a) for (auto &x: a) #define all(x) x.begin(), x.end() #ifdef TEST #define dbg(x) cout << #x << ": " << x << '\n'; #define dbgc(x) cout << #x << ":"; forin(a, x) { cout << " " << a; } cout << endl; #define tassert(x) assert(x); #else #define dbg(x) #define dbgc(x) #define tassert(x) #endif std::string solve_puzzle(std::string s, std::vector<int> c) { int tot = 0; vii l, r; forin(x, c) { l.emplace_back(tot); tot += x + 1; } string res = s; int slack = s.size() - tot + 1; rep(i, l.size()) { r.emplace_back(l[i] + c[i] + slack - 1); } vpii rem; int j = 0; rep(i, s.size()) { if (s[i] == '_') { if (r[j] < i) { j++; } int k = j; // for (int k = j; k < l.size() && i >= l[k]; k++) { if (i < l[k] + c[k]) { l[k] = i + 1; ffor(k2, k + 1, l.size()) { l[k2] = max(l[k2], l[k2 - 1] + c[k2 - 1] + 1); } } // } } } j = l.size() - 1; for (int i = s.size() - 1; i >= 0; i--) { if (s[i] == '_') { while (l[j] > i) { j--; } int k = j; // for (int k = j; k >= 0 && i <= r[k]; k--) { if (i > r[k] - c[k]) { r[k] = i - 1; for(int k2 = k - 1; k2 >= 0; k2--) { r[k2] = min(r[k2], r[k2 + 1] - c[k2 + 1] - 1); } } // } } } rep(i, l.size()) { int cslack = r[i] - l[i] + 1 - c[i]; ffor(j, l[i], l[i] + cslack) { if (res[j] == '.') { res[j] = '?'; } } ffor(j, l[i] + cslack, r[i] - cslack + 1) { res[j] = 'X'; } ffor(j, r[i] - cslack + 1, r[i] + 1) { if (res[j] == '.') { res[j] = '?'; } } } rep(i, res.size()) { if (res[i] == '.') { res[i] = '_'; } } return res; }

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

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:33:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | #define rep(i, n) for (ll i = 0; i < n; i++)
......
   57 |   rep(i, l.size()) {
      |       ~~~~~~~~~~~                   
paint.cpp:57:3: note: in expansion of macro 'rep'
   57 |   rep(i, l.size()) {
      |   ^~~
paint.cpp:33:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | #define rep(i, n) for (ll i = 0; i < n; i++)
......
   62 |   rep(i, s.size()) {
      |       ~~~~~~~~~~~                   
paint.cpp:62:3: note: in expansion of macro 'rep'
   62 |   rep(i, s.size()) {
      |   ^~~
paint.cpp:34:39: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 | #define ffor(i, a, b) for(ll i = a; i < b; i++)
......
   71 |           ffor(k2, k + 1, l.size()) {
      |                ~~~~~~~~~~~~~~~~~~~     
paint.cpp:71:11: note: in expansion of macro 'ffor'
   71 |           ffor(k2, k + 1, l.size()) {
      |           ^~~~
paint.cpp:33:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | #define rep(i, n) for (ll i = 0; i < n; i++)
......
   97 |   rep(i, l.size()) {
      |       ~~~~~~~~~~~                   
paint.cpp:97:3: note: in expansion of macro 'rep'
   97 |   rep(i, l.size()) {
      |   ^~~
paint.cpp:33:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | #define rep(i, n) for (ll i = 0; i < n; i++)
......
  113 |   rep(i, res.size()) {
      |       ~~~~~~~~~~~~~                 
paint.cpp:113:3: note: in expansion of macro 'rep'
  113 |   rep(i, res.size()) {
      |   ^~~
#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...