Submission #781729

#TimeUsernameProblemLanguageResultExecution timeMemory
781729vjudge1Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define faster ios_base::sync_with_stdio(false);cin.tie(NULL); #define OYY 1000000005 #define mod 998244353 #define mid (start+end)/2 vector <int> v,v2; int32_t main(){ faster int n;cin>>n; int r=0,g=0,sr=0,sg=0; string s;cin>>s; for(int i=0;i<n;i++){ if(s[i]=='R')sr++; else sg++; } //////////////////////////// if(n%2==0 && (sr!=sg)){ cout<<-1<<'\n'; return 0; } if(n%2==1 && !(sr+1==sg || sg+1==sr)){ cout<<-1<<'\n'; return 0; } for(int i=0;i<n;i++){ if(s[i]=='R'){ v.push_back(i); } else v2.push_back(i); } ///////////////////////////////// int cev=0; for(int i=0;i<min(v.size(),v2.size());i++){ cev+=abs(v[i]-v2[i])-1; } cout<<cev<<'\n'; return 0; }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int32_t main()':
joi2019_ho_t3.cpp:37:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'const long unsigned int' [-Wsign-compare]
   37 |     for(int i=0;i<min(v.size(),v2.size());i++){
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:13:9: warning: unused variable 'r' [-Wunused-variable]
   13 |     int r=0,g=0,sr=0,sg=0;
      |         ^
joi2019_ho_t3.cpp:13:13: warning: unused variable 'g' [-Wunused-variable]
   13 |     int r=0,g=0,sr=0,sg=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...