(This isn't supposed to be a serious post, but hopefully somebody finds it funny)
Intellegent: are you ok
Intellegent: i think you need some therapy man
Some of my submissions: (all of these were submitted in rated contests and AC'd, and none were intentionally written poorly)
My submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int n;
string one, two;
cin >> n >> one >> two;
vector<int> a(n/3+1);
vector<int> b(n/3);
vector<int> c(n/3);
a[0] = 0;
b[0] = (int)((int)(one[0] == 'A') + (int)(one[1] == 'A') + (int)(two[0] == 'A') >= 2);
c[0] = (int)((int)(one[0] == 'A') + (int)(two[0] == 'A') + (int)(two[1] == 'A') >= 2);
for(int i=1; i<=n/3; i++){
a[i] = a[i-1] + (int)((int)(one[3*(i-1)] == 'A') + (int)(one[3*(i-1)+1] == 'A') + (int)(one[3*(i-1)+2] == 'A') >= 2) + (int)((int)(two[3*(i-1)] == 'A') + (int)(two[3*(i-1)+1] == 'A') + (int)(two[3*(i-1)+2] == 'A') >= 2);
a[i] = max(a[i], b[i-1] + (int)((int)(two[3*(i-1)+1] == 'A') + (int)(two[3*(i-1)+2] == 'A') + (int)(one[3*(i-1)+2] == 'A') >= 2));
a[i] = max(a[i], c[i-1] + (int)((int)(two[3*(i-1)+2] == 'A') + (int)(one[3*(i-1)+1] == 'A') + (int)(one[3*(i-1)+2] == 'A') >= 2));
if(i<n/3){
b[i] = b[i-1] + (int)((int)(one[3*(i-1)+2] == 'A') + (int)(one[3*(i-1)+3] == 'A') + (int)(one[3*(i-1)+4] == 'A') >= 2) + (int)((int)(two[3*(i-1)+1] == 'A') + (int)(two[3*(i-1)+2] == 'A') + (int)(two[3*(i-1)+3] == 'A') >= 2);
c[i] = c[i-1] + (int)((int)(one[3*(i-1)+1] == 'A') + (int)(one[3*(i-1)+2] == 'A') + (int)(one[3*(i-1)+3] == 'A') >= 2) + (int)((int)(two[3*(i-1)+2] == 'A') + (int)(two[3*(i-1)+3] == 'A') + (int)(two[3*(i-1)+4] == 'A') >= 2);
b[i] = max(b[i], a[i] + (int)((int)(one[3*(i-1)+3] == 'A') + (int)(one[3*(i-1)+4] == 'A') + (int)(two[3*(i-1)+3] == 'A') >= 2));
c[i] = max(c[i], a[i] + (int)((int)(one[3*(i-1)+3] == 'A') + (int)(two[3*(i-1)+3] == 'A') + (int)(two[3*(i-1)+4] == 'A') >= 2));
}
}
cout << a[n/3] << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
My submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int n, k, cnt = 0, ans = 0;
cin >> n >> k;
int i=0;
for(; i<32; i++){if((n >> i) < k) break;}
int num = n & ((1 << i) - 1);
for(int j=0; j<i; j++) ans += ((n >> (j+1)) + (num & (1 << j) ? 1 : 0)) * (((num >> 1) & (~((1 << j) - 1))) + (num & (1 << j)));
cout << ans << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) solve();
}
My submission:
#include <bits/stdc++.h>
using namespace std;
void solve(){
int l, r;
cin >> l >> r;
int x = (1 << __lg(l ^ r)), y = r & ~((x << 1) - 1);
cout << y + x << ' ' << y + x - 1 << ' ' << (y + x - 2 >= l ? y + x - 2 : y + x + 1) << '\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) solve();
}
My submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int n, m;
cin >> n >> m;
vector<int> a(n), b(m), prea(n+1), sufa(n+1), preb(m+1), sufb(m+1), diffa(n/2+1), diffb(m/2+1);
for(int i=0; i<n; i++) cin >> a[i];
for(int i=0; i<m; i++) cin >> b[i];
int kmax = (max(n, m) >= 2*min(n, m) ? min(n, m) : max(n, m) - min(n, m) + 2*((2*min(n, m)-max(n, m))/3) + (int)((2*min(n, m)-max(n, m)) % 3 == 2));
cout << kmax << '\n';
sort(a.begin(), a.end()), sort(b.begin(), b.end());
for(int i=0; i<n/2; i++) prea[i+1] = prea[i] + a[i];
for(int i=0; i<m/2; i++) preb[i+1] = preb[i] + b[i];
sort(a.begin(), a.end(), greater<int>()), sort(b.begin(), b.end(), greater<int>());
for(int i=0; i<n/2; i++) sufa[i+1] = sufa[i] + a[i], diffa[i+1] = sufa[i+1] - prea[i+1];
for(int i=0; i<m/2; i++) sufb[i+1] = sufb[i] + b[i], diffb[i+1] = sufb[i+1] - preb[i+1];
int cura = 0, curb = 0;
for(int k=1; k<=kmax; k++){
if(diffa[cura+1] + diffb[curb] > diffa[cura] + diffb[curb+1]) cura++; else curb++;
while(cura > n-k){cura--; curb++;}
while(curb > m-k){curb--; cura++;}
cout << diffa[cura] + diffb[curb] << ' ';
}
cout << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) solve();
}
If I can read it, surely it's fine... right? After all, that's all that really matters.
(I would seriously question the judgment of anybody who hires me to write code, ever.)