What if “landmine codes” occur in hackable Codeforces contests?

Revision en1, by Zaoly, 2023-05-08 06:21:31

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.

Tags cheat, hack, landmine, corner case

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en20 English Zaoly 2023-07-29 10:36:22 15
en19 English Zaoly 2023-05-08 17:15:40 3 Tiny change: 'Following is the sour' -> 'Following was the sour'
en18 English Zaoly 2023-05-08 17:14:52 3 Tiny change: 'ed, which is intentio' -> 'ed, which was intentio'
en17 English Zaoly 2023-05-08 08:34:12 0 (published)
en16 English Zaoly 2023-05-08 08:06:27 17 Tiny change: 'ating.\n\n\n\n[cut]\n\n\n\nLook a' -> 'ating.\n\nLook a'
en15 English Zaoly 2023-05-08 08:05:57 8 Tiny change: 'ating.\n\n[cut]\n\nLook a' -> 'ating.\n\n\n\n[cut]\n\n\n\nLook a'
en14 English Zaoly 2023-05-08 08:05:35 14
en13 English Zaoly 2023-05-08 08:02:02 84
en12 English Zaoly 2023-05-08 07:05:12 7 Tiny change: 'ating.\n\nI’m no' -> 'ating.\n\n---\n\nI’m no'
en11 English Zaoly 2023-05-08 07:03:58 16
en10 English Zaoly 2023-05-08 07:03:24 8
en9 English Zaoly 2023-05-08 07:02:45 117
en8 English Zaoly 2023-05-08 06:57:02 19
en7 English Zaoly 2023-05-08 06:54:39 7 Tiny change: 'takes.\n\nIn a r' -> 'takes.\n\n--\n\nIn a r'
en6 English Zaoly 2023-05-08 06:54:22 96
en5 English Zaoly 2023-05-08 06:49:31 214
en4 English Zaoly 2023-05-08 06:43:09 37
en3 English Zaoly 2023-05-08 06:41:32 415
en2 English Zaoly 2023-05-08 06:35:02 614
en1 English Zaoly 2023-05-08 06:21:31 1188 Initial revision (saved to drafts)