Submission #922311

#TimeUsernameProblemLanguageResultExecution timeMemory
922311elotelo966Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
15 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define OYY LLONG_MAX #define mod 998244353 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mid (start+end)/2 #define lim 65 #define fi first #define se second int n;// 1 2 3 int cev=LLONG_MAX; vector<int> v[4]; bool stop=true; inline void dpp(int red,int gre,int yel,int sira,int renk,int tut,string st){ if(red==v[1].size() && gre==v[2].size() && yel==v[3].size()){ stop=true; cev=min(cev,tut); return ; } if(renk!=1 && red<v[1].size()){ dpp(red+1,gre,yel,sira+1,1,tut+abs(v[1][red]-sira),st+'R'); } if(renk!=2 && gre<v[2].size()){ dpp(red,gre+1,yel,sira+1,2,tut+abs(v[2][gre]-sira),st+'G'); } if(renk!=3 && yel<v[3].size()){ dpp(red,gre,yel+1,sira+1,3,tut+abs(v[3][yel]-sira),st+'Y'); } } int32_t main(){ faster cin>>n; string s;cin>>s; for(int i=0;i<n;i++){ if(s[i]=='R')v[1].push_back(i+1); else if(s[i]=='G')v[2].push_back(i+1); else v[3].push_back(i+1); } string h=""; int tt=(n+1)/2; if(v[1].size()>tt || v[2].size()>tt || v[3].size()>tt || !stop){cout<<-1<<'\n';return 0;} //cout<<dpp(0,0,0,1,0,0,h)<<'\n'; dpp(0,0,0,1,0,0,h); cout<<cev/2<<'\n'; return 0; }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'void dpp(long long int, long long int, long long int, long long int, long long int, long long int, std::string)':
joi2019_ho_t3.cpp:17:12: 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]
   17 |      if(red==v[1].size() && gre==v[2].size() && yel==v[3].size()){
      |         ~~~^~~~~~~~~~~~~
joi2019_ho_t3.cpp:17:32: 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]
   17 |      if(red==v[1].size() && gre==v[2].size() && yel==v[3].size()){
      |                             ~~~^~~~~~~~~~~~~
joi2019_ho_t3.cpp:17:52: 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]
   17 |      if(red==v[1].size() && gre==v[2].size() && yel==v[3].size()){
      |                                                 ~~~^~~~~~~~~~~~~
joi2019_ho_t3.cpp:22:23: 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]
   22 |      if(renk!=1 && red<v[1].size()){
      |                    ~~~^~~~~~~~~~~~
joi2019_ho_t3.cpp:25:23: 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]
   25 |      if(renk!=2 && gre<v[2].size()){
      |                    ~~~^~~~~~~~~~~~
joi2019_ho_t3.cpp:28:23: 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]
   28 |      if(renk!=3 && yel<v[3].size()){
      |                    ~~~^~~~~~~~~~~~
joi2019_ho_t3.cpp: In function 'int32_t main()':
joi2019_ho_t3.cpp:44:19: 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]
   44 |     if(v[1].size()>tt || v[2].size()>tt || v[3].size()>tt || !stop){cout<<-1<<'\n';return 0;}
      |        ~~~~~~~~~~~^~~
joi2019_ho_t3.cpp:44:37: 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]
   44 |     if(v[1].size()>tt || v[2].size()>tt || v[3].size()>tt || !stop){cout<<-1<<'\n';return 0;}
      |                          ~~~~~~~~~~~^~~
joi2019_ho_t3.cpp:44:55: 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]
   44 |     if(v[1].size()>tt || v[2].size()>tt || v[3].size()>tt || !stop){cout<<-1<<'\n';return 0;}
      |                                            ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...