Submission #959039

#TimeUsernameProblemLanguageResultExecution timeMemory
959039IUA_HasinPaint By Numbers (IOI16_paint)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define endl "\n" #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define ll long long using namespace std; #include "paint.h" #include <cstdlib> std::string solve_puzzle(std::string s, std::vector<int> c) { ll d = c.size(); ll arr[d]; ll brr[d]; vector<ll> v; for(int i=0; i<d; i++){ if(i==0){ arr[i] = c[i]; } else { arr[i] = arr[i-1]+c[i]+1; } } for(int i=d-1; i>=0; i--){ if(i==d-1){ brr[i] = c[i]; } else { brr[i] = brr[i+1]+c[i]+1; } } ll dd = s.length(); ll cnt = 0; ll a = arr[0]; ll b = brr[0]; for(int i=1; i<=dd; i++){ // cout<<a<<" "<<b<<endl; if(i<=a){ if(dd-b>=i){ v.push_back(i); } } else { a = arr[cnt+1]; b = brr[cnt+1]; cnt++; if(cnt>=d){ b = 0; a = arr[d-1]; } if(dd-b>=i){ v.push_back(i); } } } // for(int i=0; i<d; i++){ // cout << arr[i] << " "; // } // cout<<endl; // for(int i=0; i<d; i++){ // cout << brr[i] << " "; // } // cout<<endl; // for(int i=0; i<v.size(); i++){ // cout << v[i] << " "; // } // cout<<endl; // ll dd = s.length(); string ss; if(v.size()==d-1){ ll cnt = 1; ll a = v[0]-1; for(int i=0; i<s.length(); i++){ if(cnt>v.size()){ ss.push_back('X'); }else if(i==a){ ss.push_back('_'); a = v[cnt]-1; cnt++; } else { ss.push_back('X'); } } return ss; }else if(v.size()==0){ for(int i=0; i<s.length(); i++){ ss.push_back('X'); } return ss; } else { ll cnt = 1; ll a = v[0]-1; for(int i=0; i<s.length(); i++){ if(cnt==v.size()){ ss.push_back('?'); }else if(i==a){ ss.push_back('?'); a = v[cnt]-1; cnt++; } else { ss.push_back('X'); } } return ss; } }

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:78:16: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   78 |     if(v.size()==d-1){
      |        ~~~~~~~~^~~~~
paint.cpp:81:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |         for(int i=0; i<s.length(); i++){
      |                      ~^~~~~~~~~~~
paint.cpp:82:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |             if(cnt>v.size()){
      |                ~~~^~~~~~~~~
paint.cpp:94:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         for(int i=0; i<s.length(); i++){
      |                      ~^~~~~~~~~~~
paint.cpp:101:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |         for(int i=0; i<s.length(); i++){
      |                      ~^~~~~~~~~~~
paint.cpp:102:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |             if(cnt==v.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...