So I was debugging this code and managed input/outputs in separate files. I ran the same code with same flags in codeblocks and WSL ubuntu 18.04, they gave me two different outputs.
My Code
#include<bits/stdc++.h>
using namespace std;
int main() {
#ifdef ROBIN
freopen("in", "r", stdin);
freopen("out", "w", stdout);
#endif // ROBIN
int t, d = 0;
cin >> t;
getchar();
// getchar();
while(t--) {
d++;
string ss, tt;
// getchar();
getline(cin, ss);
// getchar();
getline(cin, tt);
string sss = "", ttt = "";
cout << "SS: " << ss << endl;
cout << "TT: " << tt << endl;
for(int i = 0; i < ss.size(); i++) {
ss[i] = tolower(ss[i]);
if(ss[i] != ' ') {
sss += ss[i];
}
}
for(int i = 0; i < tt.size(); i++) {
tt[i] = tolower(tt[i]);
if(tt[i] != ' ') {
ttt += tt[i];
}
}
sort (sss.begin(), sss.end());
sort (ttt.begin(), ttt.end());
if(sss == ttt) {
cout << "Case " << d << ": " << "Yes" << endl;
}
else {
cout << "Case " << d << ": " << "No" << endl;
}
}
return 0;
}
Input
3
Tom Marvolo Riddle
I am Lord Voldemort
I am not Harry Potter
Hi Pretty Roar to man
Harry and Voldemort
Tom and Jerry and Harry
Output (Code::Blocks)
SS: Tom Marvolo Riddle
TT: I am Lord Voldemort
Case 1: Yes
SS: I am not Harry Potter
TT: Hi Pretty Roar to man
Case 2: Yes
SS: Harry and Voldemort
TT: Tom and Jerry and Harry
Case 3: No
Output (WSL)
SS:
TT: Tom Marvolo Riddle
Case 1: No
SS: I am Lord Voldemort
TT: I am not Harry Potter
Case 2: No
SS: Hi Pretty Roar to man
TT: Harry and Voldemort
Case 3: No
I included sample input-output in the code. I would appreciate it if someone gives me a proper explanation of this. Thanks.
Flags:
-DROBIN
-std=c++14
-O2