#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); int l[2]={0,0}; char c; do {c=getchar_unlocked();} while (c!='0' && c!='1'); do {l[c^'0']++; c=getchar_unlocked();} while (c=='0' || c=='1'); l[0]-=2*n; l[1]-=3*n; if (l[0]<0 || l[1]<0) { puts("NIE"); return 0; } for (int i=0; i<n; i++) { if (l[1]>2) printf("%c",0b01101111); else if (l[1]==2) printf("%c",0b01100111); else if (l[1]==1) printf("%c",0b01100011); else if (l[1]==0) printf("%c",0b01100001); l[1]-=min(3,l[1]); } printf("\n"); return 0; }
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 | #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); int l[2]={0,0}; char c; do {c=getchar_unlocked();} while (c!='0' && c!='1'); do {l[c^'0']++; c=getchar_unlocked();} while (c=='0' || c=='1'); l[0]-=2*n; l[1]-=3*n; if (l[0]<0 || l[1]<0) { puts("NIE"); return 0; } for (int i=0; i<n; i++) { if (l[1]>2) printf("%c",0b01101111); else if (l[1]==2) printf("%c",0b01100111); else if (l[1]==1) printf("%c",0b01100011); else if (l[1]==0) printf("%c",0b01100001); l[1]-=min(3,l[1]); } printf("\n"); return 0; } |