fix: language version IDs, cache crash, and stress session restore (#352)
## Problem Codeforces language version IDs were wrong (pointed at old compiler versions), `LANGUAGE_VERSIONS` was incomplete for most platforms, the contest picker crashed when `supports_countdown` was stored as a non-table entry, and `:CP stress` restored a broken IO view on exit. ## Solution Correct CF `programTypeId` values and default to C++20. Add `LANGUAGE_VERSIONS` entries for all six platforms. Guard `get_contest_summaries` against non-table cache entries. Call `ensure_io_view()` after stress session restore. Shorten the stress terminal buffer name to a readable `term://stress.py` format.
This commit is contained in:
parent
425a8f36e9
commit
1ac521a126
6 changed files with 22 additions and 11 deletions
10
1621.rs
Normal file
10
1621.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
use std::io::{self,Read};
|
||||||
|
fn main(){
|
||||||
|
let mut s=String::new();
|
||||||
|
io::stdin().read_to_string(&mut s).unwrap();
|
||||||
|
let s=s.trim().as_bytes();
|
||||||
|
let(mut mx,mut c)=(1usize,1usize);
|
||||||
|
for i in 1..s.len(){if s[i]==s[i-1]{c+=1;}else{c=1;}if c>mx{mx=c;}}
|
||||||
|
println!("{}",mx);
|
||||||
|
}
|
||||||
|
|
||||||
0
a.cc
Normal file
0
a.cc
Normal file
|
|
@ -379,7 +379,7 @@ end
|
||||||
function M.get_contest_summaries(platform)
|
function M.get_contest_summaries(platform)
|
||||||
local contest_list = {}
|
local contest_list = {}
|
||||||
for contest_id, contest_data in pairs(cache_data[platform] or {}) do
|
for contest_id, contest_data in pairs(cache_data[platform] or {}) do
|
||||||
if contest_id:sub(1, 1) ~= '_' then
|
if type(contest_data) == 'table' and contest_id:sub(1, 1) ~= '_' then
|
||||||
table.insert(contest_list, {
|
table.insert(contest_list, {
|
||||||
id = contest_id,
|
id = contest_id,
|
||||||
name = contest_data.name,
|
name = contest_data.name,
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,10 @@ M.LANGUAGE_VERSIONS = {
|
||||||
python = { python3 = '31', pypy3 = '70' },
|
python = { python3 = '31', pypy3 = '70' },
|
||||||
},
|
},
|
||||||
cses = {
|
cses = {
|
||||||
cpp = { ['c++11'] = 'C++11', ['c++17'] = 'C++17', ['c++20'] = 'C++20' },
|
cpp = { ['c++17'] = 'C++17' },
|
||||||
python = { python3 = 'Python3', pypy3 = 'PyPy3' },
|
python = { python3 = 'Python3', pypy3 = 'PyPy3' },
|
||||||
java = { java = 'Java' },
|
java = { java = 'Java' },
|
||||||
rust = { rust2018 = 'Rust2018', rust2021 = 'Rust2021' },
|
rust = { rust2021 = 'Rust2021' },
|
||||||
},
|
},
|
||||||
kattis = {
|
kattis = {
|
||||||
cpp = { ['c++17'] = 'C++', ['c++20'] = 'C++', ['c++23'] = 'C++' },
|
cpp = { ['c++17'] = 'C++', ['c++20'] = 'C++', ['c++23'] = 'C++' },
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ local function build_run_cmd(file)
|
||||||
end
|
end
|
||||||
return './' .. bin
|
return './' .. bin
|
||||||
elseif ext == 'py' then
|
elseif ext == 'py' then
|
||||||
return 'python3 ' .. file
|
return 'python ' .. file
|
||||||
end
|
end
|
||||||
return './' .. file
|
return './' .. file
|
||||||
end
|
end
|
||||||
|
|
@ -72,6 +72,7 @@ function M.toggle(generator_cmd, brute_cmd)
|
||||||
state.saved_stress_session = nil
|
state.saved_stress_session = nil
|
||||||
end
|
end
|
||||||
state.set_active_panel(nil)
|
state.set_active_panel(nil)
|
||||||
|
require('cp.ui.views').ensure_io_view()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -128,6 +129,7 @@ function M.toggle(generator_cmd, brute_cmd)
|
||||||
vim.fn.delete(state.saved_stress_session)
|
vim.fn.delete(state.saved_stress_session)
|
||||||
state.saved_stress_session = nil
|
state.saved_stress_session = nil
|
||||||
end
|
end
|
||||||
|
require('cp.ui.views').ensure_io_view()
|
||||||
end
|
end
|
||||||
|
|
||||||
execute.compile_problem(false, function(compile_result)
|
execute.compile_problem(false, function(compile_result)
|
||||||
|
|
@ -169,6 +171,11 @@ function M.toggle(generator_cmd, brute_cmd)
|
||||||
|
|
||||||
vim.cmd.terminal(cmdline)
|
vim.cmd.terminal(cmdline)
|
||||||
local term_buf = vim.api.nvim_get_current_buf()
|
local term_buf = vim.api.nvim_get_current_buf()
|
||||||
|
pcall(
|
||||||
|
vim.api.nvim_buf_set_name,
|
||||||
|
term_buf,
|
||||||
|
("term://stress.py '%s' '%s' '%s'"):format(gen_cmd, brute_run_cmd, binary)
|
||||||
|
)
|
||||||
local term_win = vim.api.nvim_get_current_win()
|
local term_win = vim.api.nvim_get_current_win()
|
||||||
|
|
||||||
local cleaned = false
|
local cleaned = false
|
||||||
|
|
|
||||||
|
|
@ -31,24 +31,18 @@ HEADERS = {
|
||||||
CONNECTIONS = 8
|
CONNECTIONS = 8
|
||||||
|
|
||||||
CSES_LANGUAGES: dict[str, dict[str, str]] = {
|
CSES_LANGUAGES: dict[str, dict[str, str]] = {
|
||||||
"C++11": {"name": "C++", "option": "C++11"},
|
|
||||||
"C++17": {"name": "C++", "option": "C++17"},
|
"C++17": {"name": "C++", "option": "C++17"},
|
||||||
"C++20": {"name": "C++", "option": "C++20"},
|
|
||||||
"Python3": {"name": "Python3", "option": "CPython3"},
|
"Python3": {"name": "Python3", "option": "CPython3"},
|
||||||
"PyPy3": {"name": "Python3", "option": "PyPy3"},
|
"PyPy3": {"name": "Python3", "option": "PyPy3"},
|
||||||
"Java": {"name": "Java", "option": "Java"},
|
"Java": {"name": "Java", "option": "Java"},
|
||||||
"Rust2018": {"name": "Rust", "option": "2018"},
|
|
||||||
"Rust2021": {"name": "Rust", "option": "2021"},
|
"Rust2021": {"name": "Rust", "option": "2021"},
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTENSIONS: dict[str, str] = {
|
EXTENSIONS: dict[str, str] = {
|
||||||
"C++11": "cpp",
|
|
||||||
"C++17": "cpp",
|
"C++17": "cpp",
|
||||||
"C++20": "cpp",
|
|
||||||
"Python3": "py",
|
"Python3": "py",
|
||||||
"PyPy3": "py",
|
"PyPy3": "py",
|
||||||
"Java": "java",
|
"Java": "java",
|
||||||
"Rust2018": "rs",
|
|
||||||
"Rust2021": "rs",
|
"Rust2021": "rs",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -443,7 +437,7 @@ class CSESScraper(BaseScraper):
|
||||||
print(json.dumps({"status": "submitting"}), flush=True)
|
print(json.dumps({"status": "submitting"}), flush=True)
|
||||||
|
|
||||||
ext = EXTENSIONS.get(language_id, "cpp")
|
ext = EXTENSIONS.get(language_id, "cpp")
|
||||||
lang = CSES_LANGUAGES.get(language_id, {})
|
lang = CSES_LANGUAGES.get(language_id, {"name": "C++", "option": "C++17"})
|
||||||
content_b64 = base64.b64encode(source_code.encode()).decode()
|
content_b64 = base64.b64encode(source_code.encode()).decode()
|
||||||
|
|
||||||
payload: dict[str, Any] = {
|
payload: dict[str, Any] = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue