In a recent contest: Codeforces Round 871 (Div. 4), I saw a Successful hacking attempt in the Hacks list. But I think this hacking may involve cheating.
Look at this hacked submission: 204925830
The source code of the defender contained a “landmine”, which means that for some corner case, the code wouldn’t be accepted.
Following is the source code. Note the corner case that would make the code wrong.
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
string s1,s2;
int t;
int main(){
scanf("%d",&t);
s1 = "codeforces";
int ans;
while(t --){
cin >> s2;
if(s2 == "xxxxxxxxxx"){ // Here! The corner case
puts("-1"); // Wrong output
return 0;
}
ans = 0;
for(unsigned int i = 0 ; i < s1.size() ; ++i){
if(s1[i] != s2[i])
++ans;
}
printf("%d\n",ans);
}
return 0;
}
So, for the case xxxxxxxxxx
, the code would definitely get a Wrong answer.
Then view the hacking test.