#include<bits/stdc++.h> //#define int long long #define ll long long using namespace std; string alg(){ vector<char> V; //1,2,3,4 V.push_back('o');V.push_back('g');V.push_back('c');V.push_back('a'); int n;cin>>n; string s;cin>>s; int x0=0,x1=0; for(char x:s) if(x=='0')x0++; else x1++; x0-= n; x1-=2*n; if(x0<n||x1<n) return "NIE"; int c =n-x0%n; int a =x0/n; string w=""; for(int i=0;i<c;i++) w+=V[a-1]; for(int i=0;i<n-c;i++) w+=V[a]; // if((a-1+1)*c+(n-c)*(a+1)!=x0) cout << "BLAAAAAAAAAAD"; return w; } int32_t main(){ // ios::sync_with_stdio(false); cin.tie(NULL); cout << alg(); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include<bits/stdc++.h> //#define int long long #define ll long long using namespace std; string alg(){ vector<char> V; //1,2,3,4 V.push_back('o');V.push_back('g');V.push_back('c');V.push_back('a'); int n;cin>>n; string s;cin>>s; int x0=0,x1=0; for(char x:s) if(x=='0')x0++; else x1++; x0-= n; x1-=2*n; if(x0<n||x1<n) return "NIE"; int c =n-x0%n; int a =x0/n; string w=""; for(int i=0;i<c;i++) w+=V[a-1]; for(int i=0;i<n-c;i++) w+=V[a]; // if((a-1+1)*c+(n-c)*(a+1)!=x0) cout << "BLAAAAAAAAAAD"; return w; } int32_t main(){ // ios::sync_with_stdio(false); cin.tie(NULL); cout << alg(); } |