Submission #618184

#TimeUsernameProblemLanguageResultExecution timeMemory
618184rrrr10000Paint By Numbers (IOI16_paint)C++14
80 / 100
2090 ms127344 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<bool> vb; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++) #define all(a) a.begin(),a.end() #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define fi first #define se second #define pb emplace_back template<class T> void out(T a){cout<<a<<endl;} template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;} template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;} const ll inf=1001001001001001001; bool check(string s,vector<int> c){ string t; rep(i,c.size()){ if(i)t+='_'; rep(j,c[i])t+='X'; } vvi dp(s.size()+1,vi(t.size()+1)); dp[0][0]=1; rep(i,s.size())rep(j,t.size()+1)if(dp[i][j]){ if(j<t.size()&&(s[i]=='.'||s[i]==t[j]))dp[i+1][j+1]=1; if((j==0||j==t.size())&&s[i]!='X')dp[i+1][j]=1; if(j>0&&s[i]!='X'&&t[j-1]=='_')dp[i+1][j]=1; } // out(s); // out(dp[s.size()][t.size()]); return dp[s.size()][t.size()]; } std::string solve_puzzle(std::string s, std::vector<int> c) { string res=s; rep(i,s.size())if(s[i]=='.'){ s[i]='X'; if(!check(s,c))res[i]='_'; else{ s[i]='_'; if(!check(s,c))res[i]='X'; else res[i]='?'; } s[i]='.'; } return res; }

Compilation message (stderr)

paint.cpp: In function 'bool check(std::string, std::vector<int>)':
paint.cpp:33:13: 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 |         if(j<t.size()&&(s[i]=='.'||s[i]==t[j]))dp[i+1][j+1]=1;
      |            ~^~~~~~~~~
paint.cpp:34:20: 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]
   34 |         if((j==0||j==t.size())&&s[i]!='X')dp[i+1][j]=1;
      |                   ~^~~~~~~~~~
#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...