제출 #288467

#제출 시각아이디문제언어결과실행 시간메모리
288467TangentPaint By Numbers (IOI16_paint)C++17
59 / 100
1 ms384 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] == '_') { while (r[j] < i) { 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--; } 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:67:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |       for (int k = j; k < l.size() && i >= l[k]; k++) {
      |                       ~~^~~~~~~~~~
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++)
......
   70 |           ffor(k2, k + 1, l.size()) {
      |                ~~~~~~~~~~~~~~~~~~~     
paint.cpp:70:11: note: in expansion of macro 'ffor'
   70 |           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++)
......
   95 |   rep(i, l.size()) {
      |       ~~~~~~~~~~~                   
paint.cpp:95:3: note: in expansion of macro 'rep'
   95 |   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++)
......
  111 |   rep(i, res.size()) {
      |       ~~~~~~~~~~~~~                 
paint.cpp:111:3: note: in expansion of macro 'rep'
  111 |   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...