(For codeforces global round 5.)
There are some users who submit the same code for C1 and C2, but get main test failed for C1 and passed for C2.
This JavaScript code shows that there are 12 users who passed C1 and failed C2:
Code
function sleep(ms){
return new Promise(function(resolve,reject){
setTimeout(resolve,ms)
})
}
async function custom_test(source,programTypeId,input){
// There's no official API
// adapt from CF customtest js code
const data=await $.post('/data/customtest',{
csrf_token: Codeforces.getCsrfToken(),
source: source,
sourceCode: source,
tabSize: 4,
programTypeId: programTypeId,
input: input,
output: '', // not
_tta: 510, // ?
communityCode: '',
action: 'submitSourceCode',
})
while(true){
sleep(2500)
const response=await $.post("/data/customtest", {
communityCode: "",
action: "getVerdict",
customTestSubmitId: data.customTestSubmitId
})
if (response["verdict"] != null && response["verdict"] != undefined &&
response["customTestSubmitId"] == data.customTestSubmitId) {
// var result = response["output"] + "\n=====\nUsed: " + response["stat"];
return response
}
}
}
function lang_id(name){
// There's no official API
/* TODO:
{ // from codeforces customtest page
43:"GNU GCC C11 5.1.0",
52:"Clang++17 Diagnostics",
42:"GNU G++11 5.1.0",
50:"GNU G++14 6.4.0",
54:"GNU G++17 7.3.0",
2:"Microsoft Visual C++ 2010",
59:"Microsoft Visual C++ 2017",
9:"C# Mono 5.18",
28:"D DMD32 v2.086.0",
32:"Go 1.12.6",
12:"Haskell GHC 8.6.3",
36:"Java 1.8.0_162",
48:"Kotlin 1.3.10",
19:"OCaml 4.02.1",
3:"Delphi 7",
4:"Free Pascal 3.0.2",
51:"PascalABC.NET 3.4.2",
13:"Perl 5.20.1",
6:"PHP 7.2.13",
7:"Python 2.7.15",
31:"Python 3.7.2",
40:"PyPy 2.7 (7.1.1)",
41:"PyPy 3.6 (7.1.1)",
8:"Ruby 2.0.0p645",
49:"Rust 1.35.0",
20:"Scala 2.12.8",
34:"JavaScript V8 4.8.0",
55:"Node.js 9.4.0",
14:"ActiveTcl 8.5",
15:"Io-2008-01-07 (Win32)",
17:"Pike 7.8",
18:"Befunge",
22:"OpenCobol 1.0",
25:"Factor",
26:"Secret_171",
27:"Roco",
33:"Ada GNAT 4",
38:"Mysterious Language",
39:"FALSE",
44:"Picat 0.9",
47:"J",
56:"Microsoft Q#",
57:"Text",
}
var extensionMap = { // from codeforces customtest page
"43":"program.c",
"52":"program.cpp",
"42":"program.cpp",
"50":"program.cpp",
"54":"program.cpp",
"2":"program.cpp",
"59":"program.cpp",
"9":"program.cs",
"28":"program.d",
"32":"program.go",
"12":"program.hs",
"36":"[^{}]*public\\s+(final)?\\s*class\\s+(\\w+).*|$2.java",
"48":"program.kt",
"19":"program.ml",
"3":"program.dpr",
"4":"program.pas",
"51":"program.pas",
"13":"program.pl",
"6":"program.php",
"7":"program.py",
"31":"a.py",
"40":"a.py",
"41":"a.py",
"8":"program.rb",
"49":"program.rs",
"20":"[^{}]*object\\s+(\\w+).*|$1.scala",
"34":"program.js",
"55":"program.js",
"14":"program.tcl",
"15":"program.io",
"17":"program.pike",
"18":"program.bfng",
"22":"program.opencobol",
"25":"program.factor",
"26":"program.secret_171",
"27":"program.roco",
"33":"program.ada",
"38":"program.f",
"39":"program.false",
"44":"program.pi",
"47":"program.ijs",
"56":"program.qs",
"57":"program.txt",
};
extensions = {
'GNU C': '.c',
'GNU C11': '.c',
'Clang++17 Diagnostics': '.cpp',
'GNU C++': '.cpp',
'GNU C++11': '.cpp',
'GNU C++14': '.cpp',
'GNU C++17': '.cpp',
'GNU C++17 Diagnostics': '.cpp',
'MS C++': '.cpp',
'Mono C#': '.cs',
'D': '.d',
'Go': '.go',
'Haskell': '.hs',
'Java 8': '.java',
'Kotlin': '.kt',
'Ocaml': '.ml',
'Delphi': '.dpr',
'FPC': '.pas',
'PascalABC.NET': '.pas',
'Perl': '.pl',
'PHP': '.php',
'Python 2': '.py',
'Python 3': '.py',
'PyPy 2': '.py',
'PyPy 3': '.py',
'Ruby': '.rb',
'Rust': '.rs',
'Scala': '.scala',
'JavaScript': '.js',
'Node.js': '.js',
'Q#': '.qs',
} // https://github.com/ISKU/Codeforces-Solutions-Downloader/blob/master/option.py
*/
return 50; // gnu g++14
}
async function get_source_code(contestId,submissionId){
// There's no official API. Parse from the HTML of the submission page
const x=await $.get('https://codeforces.me/contest/'+contestId+'/submission/'+submissionId)
const pageHTML=$.parseHTML(x)
const source=$(pageHTML).find('pre#program-source-text').text()
const tableHeader=$(pageHTML).find('th:contains("Lang")')[0]
const headerRow=tableHeader.parentElement
const languageColumnIndex=$(headerRow).find("th").index(tableHeader) // usually 3 but Codeforces may add columns
const lang=headerRow.nextElementSibling.children[languageColumnIndex].textContent.trim()
return [source,lang /* short language name */ ]
}
function testAllSubmissionsAgainstTest(contestId,test){
// returns immediately, print output to the console when done.
// Note: use Codeforces custom test to test. All at once. MAKE SURE that test.length is small
// otherwise Codeforces servers may be overloaded
if(test.length>=20)
throw new Error("Don't do this!")
t.forEach(async function(submissionId){
const [source,lang]=await get_source_code(contestId,submissionId)
const output=await custom_test(source,lang_id(lang) /* TODO fix lang_id */,test)
console.log('https://codeforces.me/contest/'+contestId+'/submission/'+submissionId,output)
})
}
async function main(contestId=1237){
const submissionsRequest=$.get('https://codeforces.me/api/contest.status?contestId='+contestId+'&from=1&count=10000000')
const x=await $.get('https://codeforces.me/api/contest.standings?contestId='+contestId+'&from=1&count=10000000&showUnofficial=false')
const d=await submissionsRequest
const y=x.result.rows.filter(x=>x.problemResults[3].points>0&&x.problemResults[2].points==0)
const t=y.map(z=>d.result.find(
t=>t.relativeTimeSeconds==z.problemResults[3].bestSubmissionTimeSeconds&&t.author.members[0].handle==z.party.members[0].handle
).id)
return t
}
Output:
> await main()
[62717661, 62729922, 62715435, 62717690, 62726047, 62727939, 62714189, 62716789, 62721112, 62730345, 62719766, 62719548]
I didn't write code to check how many of those submit the same code, but you can check manually that there's at least one by user Simon (rank 242) (side note: that user receives a T-shirt.)