제출 #823284

#제출 시각아이디문제언어결과실행 시간메모리
823284tolbiPaint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
#pragma optimize("Bismillahirrahmanirrahim") //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█■█ //█─█─█▄─█▄─█─█─█─█ //ahmet23 orz... //FatihSultanMehmedHan(ortanca da orz) //AbdulhamidHan //YavuzSultanSelimHan #define author tolbi #include <bits/stdc++.h> using namespace std; template<typename X, typename Y> istream& operator>>(istream& is, pair<X,Y> &pr){return is>>pr.first>>pr.second;} template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr){return os<<pr.first<<" "<<pr.second;} template<typename T> istream& operator>>(istream& is, vector<T> &arr){for (auto &it : arr) is>>it;return is;} template<typename T> ostream& operator<<(ostream& os, vector<T> arr){for (auto &it : arr) os<<it<<" ";return os;} template<typename T, size_t Y> istream& operator>>(istream& is, array<T,Y> &arr){for (auto &it : arr) is>>it;return is;} template<typename T, size_t Y> ostream& operator<<(ostream& os, array<T,Y> arr){for (auto &it : arr) os<<it<<" ";return os;} template<typename T> void coutarr(T __arr){for (auto &it : __arr){cout<<it<<" ";}cout<<endl;} #define deci(x) int x;cin>>x; #define decstr(x) string x;cin>>x; #define endl '\n' #define sortarr(x) sort(x.begin(), x.end()) #define sortrarr(x) sort(x.rbegin(), x.rend()) #define rev(x) reverse(x.begin(), x.end()) #define vint(x) vector<int> x #define tol(bi) (1LL<<((int64_t)(bi))) typedef long long ll; const int MOD = 1e9+7; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); #include "paint.h" #include <cstdlib> string solve_puzzle(string s, vector<int> c) { int n = s.length(); int m = c.size(); vector<vector<int>> dp(n, vector<int>(m,-1)); string rval = s; function<bool(int,int)> f; vector<pair<int,int>> w_; vector<pair<int,int>> wx; vector<int> pref(n); vector<int> pre2(n); for (int i = 0; i < n; i++){ if (s[i]=='_') pref[i]=1; if (i) pref[i]+=pref[i-1]; if (s[i]=='X') pref2[i]=1; if (i) pref2[i]+=pref2[i-1]; } function<bool(int,int)> ava = [&](int l, int r){ int hyd = 0; if (l) hyd=pref[l-1]; return (pref[r]==hyd); }; function<bool(int,int)> arax = [&](int l, int r){ int hyd = 0; if (l) hyd=pref2[l-1]; return (pref2[r]!=hyd); }; f = [&](int node, int flag)->bool{ if (flag>=m){ if (node>=n) return true; if (arax(node,n-1)) return false; w_.push_back({node,n-1}); return true; } if (node>=n) return false; if (dp[node][flag]!=-1) return dp[node][flag]; dp[node][flag]=0; int l = node; int r = node+c[flag]-1; if (r>=n) return false; if (s[node]!='X' && f(node+1,flag)) { w_.push_back({node,node}); dp[node][flag]=1; } if (ava(l,r) && f(r+2,flag+1)) { if (r==n-1 || s[r+1]!='X'){ wx.push_back({l,r}); w_.push_back({r+1,r+1}); dp[node][flag]=1; } } return dp[node][flag]; }; f(0,0); vector<int> ans(n,0); vector<pair<int,int>> isl; for (int i = 0; i < wx.size(); i++){ if (wx[i].second<wx[i].first) continue; isl.push_back({wx[i].first,1}); isl.push_back({wx[i].second+1,-1}); } sortrarr(isl); int crr = 0; for (int i = 0; i <= n; i++){ while (isl.size() && isl.back().first<=i){ crr+=isl.back().second; isl.pop_back(); } if (i<n && crr>0) ans[i]|=1; } isl.clear(); for (int i = 0; i < w_.size(); i++){ if (w_[i].second<w_[i].first) continue; isl.push_back({w_[i].first,1}); isl.push_back({w_[i].second+1,-1}); } sortrarr(isl); crr = 0; for (int i = 0; i <= n; i++){ while (isl.size() && isl.back().first<=i){ crr+=isl.back().second; isl.pop_back(); } if (i<n && crr>0) ans[i]|=2; } for (int i = 0; i < n; i++){ if (ans[i]==1) rval[i]='X'; else if (ans[i]==2) rval[i]='_'; else rval[i]='?'; } return rval; }

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

paint.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:47:18: error: 'pref2' was not declared in this scope; did you mean 'pre2'?
   47 |   if (s[i]=='X') pref2[i]=1;
      |                  ^~~~~
      |                  pre2
paint.cpp:48:10: error: 'pref2' was not declared in this scope; did you mean 'pre2'?
   48 |   if (i) pref2[i]+=pref2[i-1];
      |          ^~~~~
      |          pre2
paint.cpp: In lambda function:
paint.cpp:57:14: error: 'pref2' was not declared in this scope; did you mean 'pre2'?
   57 |   if (l) hyd=pref2[l-1];
      |              ^~~~~
      |              pre2
paint.cpp:58:11: error: 'pref2' was not declared in this scope; did you mean 'pre2'?
   58 |   return (pref2[r]!=hyd);
      |           ^~~~~
      |           pre2
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:59:2: error: conversion from 'solve_puzzle(std::string, std::vector<int>)::<lambda(int, int)>' to non-scalar type 'std::function<bool(int, int)>' requested
   59 |  };
      |  ^
paint.cpp:89:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |  for (int i = 0; i < wx.size(); i++){
      |                  ~~^~~~~~~~~~~
paint.cpp:104:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |  for (int i = 0; i < w_.size(); i++){
      |                  ~~^~~~~~~~~~~