Git Product home page Git Product logo

snowchains's Issues

`https://atcoder.jp/contests/{}/submit` returns 404

Successfully submitted the code
┌───────────────────┬───────────────────────────────────────────────────────────┐
│ Language ID       │ 4050                                                      │
├───────────────────┼───────────────────────────────────────────────────────────┤
│ Size              │ 228                                                       │
├───────────────────┼───────────────────────────────────────────────────────────┤
│ URL (submissions) │ https://atcoder.jp/contests/practice/submissions/me       │
├───────────────────┼───────────────────────────────────────────────────────────┤
│ URL (detail)      │ https://atcoder.jp/contests/practice/submissions/18710212 │
└───────────────────┴───────────────────────────────────────────────────────────┘
error: expected [200, 302], got 404 Not Found
  • 提出自体はちゃんとされている。
  • 直後にcargo compete w sするとちゃんと表示される。

明らかにおかしい挙動なのでAtCoder側で直るのを待ってもいいかもしれないが、今日はABCがあるのでその数時間前にはworkaroundを追加する。

Cannot handle large input/output

...?

Screenshot

pub fn judge<C: 'static + Future<Output = tokio::io::Result<()>> + Send>(
draw_target: ProgressDrawTarget,
ctrl_c: fn() -> C,
cmd: &CommandExpression,
test_cases: &[BatchTestCase],
) -> anyhow::Result<JudgeOutcome> {
let num_test_cases = test_cases.len();
let quoted_name_width = test_cases
.iter()
.flat_map(|BatchTestCase { name, .. }| name.as_ref())
.map(|s| format!("{:?}", s).width())
.max()
.unwrap_or(0);
let mp = MultiProgress::with_draw_target(draw_target);
let mut targets = vec![];
for (i, test_case) in test_cases.iter().enumerate() {
let pb = mp.add(ProgressBar::new_spinner());
pb.set_style(progress_style("{prefix}{spinner} {msg:bold}"));
pb.set_prefix(&format!(
"{}/{} ({} ",
align_right(&(i + 1).to_string(), num_test_cases.to_string().len()),
num_test_cases,
align_left(
&format!("{:?})", test_case.name.as_deref().unwrap_or("")),
quoted_name_width + 1,
),
));
pb.set_message("Judging...");
pb.enable_steady_tick(50);
targets.push((cmd.build(), test_case.clone(), pb));
}
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_io()
.enable_time()
.build()?;
let outcome = rt.spawn(async move {
let num_targets = targets.len();
let (ctrl_c_tx, ctrl_c_rx) = tokio::sync::broadcast::channel(cmp::max(1, num_targets));
let mut ctrl_c_rxs = iter::once(ctrl_c_rx)
.chain(iter::repeat_with(|| ctrl_c_tx.subscribe()))
.take(num_targets)
.collect::<Vec<_>>();
tokio::task::spawn(async move {
let err_msg = match ctrl_c().await {
Ok(()) => "Recieved Ctrl-C".to_owned(),
Err(err) => err.to_string(),
};
ctrl_c_tx.send(err_msg).unwrap();
});
let (job_start_tx, mut job_start_rx) = tokio::sync::mpsc::channel(num_cpus::get());
for _ in 0..num_cpus::get() {
job_start_tx.send(()).await?;
}
let mut results = vec![];
for (i, (mut cmd, test_case, pb)) in targets.into_iter().enumerate() {
job_start_rx.recv().await;
let job_start_tx = job_start_tx.clone();
let mut ctrl_c_rx = ctrl_c_rxs.pop().expect("should have enough length");
results.push(tokio::task::spawn(async move {
let finish_pb = |verdict: &Verdict| {
tokio::task::block_in_place(|| {
pb.set_style(progress_style(&format!(
"{{prefix}}{{msg:{}}}",
verdict.summary_style(),
)));
pb.finish_with_message(&verdict.summary());
});
};
let test_case_name = test_case.name.clone();
let timelimit = test_case.timelimit;
let stdin = test_case.input.clone();
let expected = test_case.output.clone();
let started = Instant::now();
let mut child = cmd.spawn()?;
if let Some(mut child_stdin) = child.stdin.take() {
child_stdin.write_all((*stdin).as_ref()).await?;
}
macro_rules! with_ctrl_c {
($future:expr) => {
select! {
__output = $future => __output,
err_msg = ctrl_c_rx.recv().fuse() => {
let _ = child.kill();
bail!("{}", err_msg?);
},
}
};
}
let status = if let Some(timelimit) = timelimit {
let timeout = timelimit + Duration::from_millis(100);
if let Ok(status) =
with_ctrl_c!(tokio::time::timeout(timeout, child.wait()).fuse())
{
status?
} else {
let _ = child.kill();
let verdict = Verdict::TimelimitExceeded {
test_case_name,
timelimit,
stdin,
expected,
};
finish_pb(&verdict);
return Ok((i, verdict));
}
} else {
with_ctrl_c!(child.wait().fuse())?
};
let elapsed = Instant::now() - started;
let (mut stdout, mut stderr) = ("".to_owned(), "".to_owned());
if let Some(mut child_stdout) = child.stdout {
child_stdout.read_to_string(&mut stdout).await?;
}
if let Some(mut child_stderr) = child.stderr {
child_stderr.read_to_string(&mut stderr).await?;
}
let (stdout, stderr) = (Arc::from(stdout), Arc::from(stderr));
let verdict = if matches!(timelimit, Some(t) if t < elapsed) {
Verdict::TimelimitExceeded {
test_case_name,
timelimit: timelimit.unwrap(),
stdin,
expected,
}
} else if !status.success() {
Verdict::RuntimeError {
test_case_name,
elapsed,
stdin,
stdout,
stderr,
expected,
status,
}
} else if !test_case.output.accepts(&stdout) {
Verdict::WrongAnswer {
test_case_name,
elapsed,
stdin,
stdout,
stderr,
expected,
}
} else {
Verdict::Accepted {
test_case_name,
elapsed,
stdin,
stdout,
stderr,
expected,
}
};
finish_pb(&verdict);
job_start_tx.send(()).await?;
Ok::<_, anyhow::Error>((i, verdict))
}));
}
let mut verdicts = vec![None; num_targets];
for result in results {
let (i, element) = result.await??;
verdicts[i] = Some(element);
}
let verdicts = verdicts.into_iter().map(Option::unwrap).collect();
Ok::<_, anyhow::Error>(JudgeOutcome { verdicts })
});
mp.join()?;
return rt.block_on(outcome)?;
fn progress_style(template: impl AsRef<str>) -> ProgressStyle {
ProgressStyle::default_spinner().template(template.as_ref())
}
fn align_left(s: &str, n: usize) -> String {
let spaces = n.saturating_sub(s.width());
s.chars().chain(itertools::repeat_n(' ', spaces)).collect()
}
fn align_right(s: &str, n: usize) -> String {
let spaces = n.saturating_sub(s.width());
itertools::repeat_n(' ', spaces).chain(s.chars()).collect()
}
}

Parsing error on codeforces contests with admin rights

Trying to get problem names from a codeforces contest where the logged in user has admin rights fails because the html table has an extra row which is not a problem.

A potential fix is to use filter_map instead of map then collecting into Option<Vec<_>> here:
https://github.com/qryxip/snowchains/blob/master/snowchains_core/src/web/codeforces.rs#L518

But I don't know if this is the best solution, since maybe it can silently skip problems if the table looks different for other reasons.

example-table

HTML for the last two rows in from the screenshot:

<tr class="accepted-problem">
                <td class="id dark left">
                        <a href="/contest/1628/problem/F">
                            F
                        </a>
                </td>
            <td class="dark">
                <div style="position: relative;">
                    <div style="float: left;">
                            <a href="/contest/1628/problem/F"><!--
                        -->Spaceship Crisis Management<!--
                 --></a><!--
                 -->
                    </div>
                        <div style="position:absolute;right:0;top:-0.5em;font-size:1rem;padding-top:1px;text-align:right;" class="notice">

                                    <div>
                                        standard input/output
                                    </div>
                            8 s, 256 MB
                        </div>
                </div>
            </td>
            <td class="act dark">

                <span class="act-item">
            <a href="/contest/1628/submit/F"><img src="//cdn.codeforces.com/s/78453/images/icons/submit-22x22.png" title="Submit" alt="Submit"></a>
        </span>

                        <span class="act-item" style="position: relative; bottom: 2px;"><span>
            <img style="cursor: pointer" class="toggle-favourite add-favourite" title="Add to favourites" alt="Add to favourites" data-type="PROBLEM" data-entityid="1270548" data-size="16" src="//cdn.codeforces.com/s/78453/images/icons/star_gray_16.png">
    </span></span>

            </td>
                <td style="font-size: 1.1rem;" class="dark">
                        <a title="Participants solved the problem" href="/contest/1628/status/F"><img style="vertical-align: middle;" src="//cdn.codeforces.com/s/78453/images/icons/user.png">&nbsp;x58</a>
                </td>
                <td class="dark right">
                    <a href="/contest/1628/problems/edit/1270548"><img src="//cdn.codeforces.com/s/78453/images/actions/edit.png" alt="Edit" title="Edit"></a>
                </td>

            </tr><tr>
                    <td class="id bottom left">
                        <a href="/contest/1628/problems/new"><img src="//cdn.codeforces.com/s/78453/images/icons/new-problem-16x16.png"></a>
                    </td>
                <td colspan="4" class="bottom right">
                    <div style="position: relative;">
                        <div style="float: left;">
                            <a href="/contest/1628/problems/new">Add new problem</a>
                            |
                            <a href="/contest/1628/problems/newFromContest">
                                Add new problems from contest
                            </a>
                        </div>
                    </div>
                </td>
            </tr>

"小数誤差許容問題" in yukicoder

let caps = static_regex!("(通常|スペシャルジャッジ|リアクティブ)問題")
.captures(text)?;
match &caps[1] {
"通常" => Kind::Regular,
"スペシャルジャッジ" => Kind::Special,
"リアクティブ" => Kind::Reactive,
_ => return None,
}

No.1230 Hall_and_me - yukicoder

実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が10^-8以下。ただし、ジャッジ側の都合で500桁未満にしてください

Dhall cannot parse Windows absolute path

状況

$ snowchains r t
Error: Could not evalute `C:\Users\path-to-config\snowchains.dhall`

Caused by:
     --> 3:15
      |
    3 | let config = C:\Users\path-to-config\snowchains.dhall␊
      |               ^---
      |
      = expected import_alt, bool_or, natural_plus, text_append, list_append, bool_and, natural_times, bool_eq, bool_ne, combine, combine_types, equivalent, prefer, arrow, or let_binding

発生個所

snowchains/src/config.rs

Lines 173 to 185 in d65d411

serde_dhall::from_str(&format!(
r"let relativePathSegments = {}
let config = {}
in {{ service = config.detectServiceFromRelativePathSegments relativePathSegments
, contest = config.detectContestFromRelativePathSegments relativePathSegments
, problem = config.detectProblemFromRelativePathSegments relativePathSegments
, language = config.detectLanguageFromRelativePathSegments relativePathSegments
}}
",
rel_path_components, path,
))

Failed at SanityCheck

なにか壊れてませんか?

$ mkdir snowchains-test
$ cd snowchains-test
$ snowchains i .
Wrote `/home/ubuntu/Desktop/snowchains-test/snowchains.dhall`
$ snowchains x setup atcoder practice cpp code
Error: Could not evalute `/home/ubuntu/Desktop/snowchains-test/snowchains.dhall`

Caused by:
    SanityCheck

Add `Checker` variant to `match`

match:
  Checker:
    cmd: cat "$ACTUAL_OUTPUT" | cargo run --bin check-a
    shell: Bash
match:
  Checker:
    cmd: ~/.cache/online-judge-tools/library-checker-problems/math/sqrt_mod/checker "$INPUT" "$ACTUAL_OUTPUT" "$EXPECTED_OUTPUT"
    shell: Bash

Build failure on E0599

このあと rustup update ってしてからもう一度試したら通ったんですが、Rust 処理系の特定のバージョンでしか動かないなら README に書くか Cargo.toml の設定で弾くなどをしておいてほしい

$ cargo --version
cargo 1.42.0 (86334295e 2020-01-31)

$ rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

$ cargo install snowchains
    Updating crates.io index
  Downloaded snowchains v0.5.0
  Downloaded 1 crate (49.8 KB) in 1.49s
  Installing snowchains v0.5.0
  Downloaded indexmap v1.5.1
  Downloaded termcolor v1.1.0
  Downloaded rprompt v1.0.5
  Downloaded serde_yaml v0.8.13
  Downloaded anyhow v1.0.32
  Downloaded dirs v3.0.1
  Downloaded atty v0.2.14
  Downloaded either v1.6.0
  Downloaded structopt v0.3.16
  Downloaded tempfile v3.1.0
  Downloaded strum v0.18.0
  Downloaded shell-escape v0.1.5
  Downloaded serde v1.0.115
  Downloaded reqwest v0.10.7
  Downloaded maplit v1.0.2
  Downloaded rpassword v4.0.5
  Downloaded serde_json v1.0.57
  Downloaded heck v0.3.1
  Downloaded tokio v0.2.22
  Downloaded url v2.1.1
  Downloaded human-size v0.4.1
  Downloaded fwdansi v1.1.0
  Downloaded serde_dhall v0.5.3
  Downloaded az v1.0.0
  Downloaded snowchains_core v0.4.2
  Downloaded indicatif v0.15.0
  Downloaded dhall v0.5.3
  Downloaded mime v0.3.16
  Downloaded http v0.2.1
  Downloaded linked-hash-map v0.5.3
  Downloaded signal-hook-registry v1.2.1
  Downloaded mio-uds v0.6.8
  Downloaded structopt-derive v0.4.9
  Downloaded num_cpus v1.13.0
  Downloaded yaml-rust v0.4.4
  Downloaded futures-core v0.3.5
  Downloaded rustls v0.18.1
  Downloaded base64 v0.12.3
  Downloaded libc v0.2.76
  Downloaded cookie_store v0.12.0
  Downloaded tokio-tls v0.3.1
  Downloaded autocfg v1.0.1
  Downloaded mime_guess v2.0.3
  Downloaded ryu v1.0.5
  Downloaded dtoa v0.4.6
  Downloaded ppv-lite86 v0.2.9
  Downloaded doc-comment v0.3.3
  Downloaded hyper-tls v0.4.3
  Downloaded rand_pcg v0.2.1
  Downloaded encoding_rs v0.8.23
  Downloaded http-body v0.3.1
  Downloaded webpki-roots v0.19.0
  Downloaded remove_dir_all v0.5.3
  Downloaded clap v2.33.3
  Downloaded log v0.4.11
  Downloaded ipnet v2.3.0
  Downloaded idna v0.2.0
  Downloaded fnv v1.0.7
  Downloaded matches v0.1.8
  Downloaded itoa v0.4.6
  Downloaded serde_urlencoded v0.6.1
  Downloaded strum_macros v0.18.0
  Downloaded memchr v2.3.3
  Downloaded unicode-segmentation v1.6.0
  Downloaded mio v0.6.22
  Downloaded percent-encoding v2.1.0
  Downloaded hyper v0.13.7
  Downloaded slab v0.4.2
  Downloaded iovec v0.1.4
  Downloaded futures-util v0.3.5
  Downloaded dhall_proc_macros v0.5.0
  Downloaded serde_derive v1.0.115
  Downloaded hashbrown v0.8.2
  Downloaded pin-project-lite v0.1.7
  Downloaded bytes v0.5.6
  Downloaded hyper-rustls v0.21.0
  Downloaded tokio-rustls v0.14.0
  Downloaded syn v1.0.38
  Downloaded fs2 v0.4.3
  Downloaded futures-io v0.3.5
  Downloaded socket2 v0.3.12
  Downloaded pest v2.1.3
  Downloaded time v0.2.16
  Downloaded unicode-normalization v0.1.13
  Downloaded rayon v1.3.1
  Downloaded hex v0.4.2
  Downloaded strsim v0.8.0
  Downloaded unicase v2.6.0
  Downloaded proc-macro-hack v0.5.18
  Downloaded humantime-serde v1.0.0
  Downloaded publicsuffix v1.5.4
  Downloaded proc-macro2 v1.0.19
  Downloaded walkdir v2.3.1
  Downloaded futures-channel v0.3.5
  Downloaded textwrap v0.11.0
  Downloaded want v0.3.0
  Downloaded vec_map v0.8.2
  Downloaded pin-utils v0.1.0
  Downloaded tower-service v0.3.0
  Downloaded pin-project v0.4.23
  Downloaded regex v1.3.9
  Downloaded unicode-width v0.1.8
  Downloaded time v0.1.43
  Downloaded sha2 v0.9.1
  Downloaded proc-macro-error v1.0.4
  Downloaded humantime v2.0.1
  Downloaded ignore v0.4.16
  Downloaded chrono v0.4.15
  Downloaded abnf_to_pest v0.5.0
  Downloaded futures-macro v0.3.5
  Downloaded smallvec v1.4.2
  Downloaded derive_more v0.99.9
  Downloaded console v0.12.0
  Downloaded pest_generator v2.1.3
  Downloaded httparse v1.3.4
  Downloaded unicode-bidi v0.3.4
  Downloaded cookie v0.14.2
  Downloaded sha2 v0.8.2
  Downloaded quote v1.0.7
  Downloaded h2 v0.2.6
  Downloaded derivative v2.1.1
  Downloaded webpki v0.21.3
  Downloaded prettytable-rs v0.8.0
  Downloaded tracing v0.1.19
  Downloaded proc-macro-nested v0.1.6
  Downloaded once_cell v1.4.1
  Downloaded sct v0.6.0
  Downloaded arc-swap v0.4.7
  Downloaded futures-task v0.3.5
  Downloaded net2 v0.2.34
  Downloaded ansi_term v0.11.0
  Downloaded scraper v0.12.0
  Downloaded pest_consume v1.0.5
  Downloaded ring v0.16.15
  Downloaded easy-ext v0.2.2
  Downloaded strum v0.19.2
  Downloaded number_prefix v0.3.0
  Downloaded serde_cbor v0.9.0
  Downloaded annotate-snippets v0.7.0
  Downloaded unicode-xid v0.2.1
  Downloaded block-buffer v0.7.3
  Downloaded memoffset v0.5.5
  Downloaded num-integer v0.1.43
  Downloaded terminal_size v0.1.13
  Downloaded ucd-trie v0.1.3
  Downloaded untrusted v0.7.1
  Downloaded try-lock v0.2.3
  Downloaded standback v0.2.9
  Downloaded csv v1.1.3
  Downloaded termios v0.3.2
  Downloaded regex-syntax v0.6.18
  Downloaded tendril v0.4.1
  Downloaded tracing-core v0.1.14
  Downloaded tinyvec v0.3.4
  Downloaded proc-macro-error-attr v1.0.4
  Downloaded encode_unicode v0.3.6
  Downloaded pin-project-internal v0.4.23
  Downloaded opaque-debug v0.3.0
  Downloaded thread_local v1.0.1
  Downloaded dirs-sys v0.3.5
  Downloaded native-tls v0.2.4
  Downloaded cc v1.0.59
  Downloaded error-chain v0.12.4
  Downloaded digest v0.8.1
  Downloaded rayon-core v1.7.1
  Downloaded pest_meta v2.1.3
  Downloaded aho-corasick v0.7.13
  Downloaded html5ever v0.25.1
  Downloaded half v1.6.0
  Downloaded version_check v0.9.2
  Downloaded tokio-util v0.3.1
  Downloaded num-traits v0.2.12
  Downloaded getopts v0.2.21
  Downloaded cpuid-bool v0.1.2
  Downloaded globset v0.4.5
  Downloaded same-file v1.0.6
  Downloaded digest v0.9.0
  Downloaded block-buffer v0.9.0
  Downloaded opaque-debug v0.2.3
  Downloaded pretty v0.5.2
  Downloaded fake-simd v0.1.2
  Downloaded pest_derive v2.1.0
  Downloaded term v0.5.2
  Downloaded spin v0.5.2
  Downloaded time-macros v0.1.0
  Downloaded abnf v0.6.1
  Downloaded futures-sink v0.3.5
  Downloaded cssparser v0.27.2
  Downloaded strum_macros v0.19.2
  Downloaded selectors v0.22.0
  Downloaded pest_consume_macros v1.0.5
  Downloaded ego-tree v0.6.2
  Downloaded bstr v0.2.13
  Downloaded csv-core v0.1.10
  Downloaded byte-tools v0.3.1
  Downloaded utf-8 v0.7.5
  Downloaded markup5ever v0.10.0
  Downloaded generic-array v0.14.4
  Downloaded futf v0.1.4
  Downloaded dirs v1.0.5
  Downloaded openssl v0.10.30
  Downloaded generic-array v0.12.3
  Downloaded block-padding v0.1.5
  Downloaded openssl-sys v0.9.58
  Downloaded typed-arena v1.7.0
  Downloaded openssl-probe v0.1.2
  Downloaded cssparser-macros v0.6.0
  Downloaded time-macros-impl v0.1.1
  Downloaded phf v0.8.0
  Downloaded crossbeam-queue v0.2.3
  Downloaded mac v0.1.1
  Downloaded foreign-types v0.3.2
  Downloaded typenum v1.12.0
  Downloaded servo_arc v0.1.1
  Downloaded precomputed-hash v0.1.1
  Downloaded new_debug_unreachable v1.0.4
  Downloaded string_cache v0.8.0
  Downloaded regex-automata v0.1.9
  Downloaded dtoa-short v0.3.2
  Downloaded phf_codegen v0.8.0
  Downloaded phf_shared v0.8.0
  Downloaded string_cache_codegen v0.5.1
  Downloaded pkg-config v0.3.18
  Downloaded fxhash v0.2.1
  Downloaded phf_macros v0.8.0
  Downloaded thin-slice v0.1.1
  Downloaded foreign-types-shared v0.1.1
  Downloaded nodrop v0.1.14
  Downloaded siphasher v0.3.3
  Downloaded phf_generator v0.8.0
  Downloaded stable_deref_trait v1.2.0
  Downloaded nom v5.1.2
  Downloaded lexical-core v0.7.4
  Downloaded arrayvec v0.5.1
  Downloaded static_assertions v1.1.0
   Compiling proc-macro2 v1.0.19
   Compiling unicode-xid v0.2.1
   Compiling libc v0.2.76
   Compiling syn v1.0.38
   Compiling cfg-if v0.1.10
   Compiling autocfg v1.0.1
   Compiling version_check v0.9.2
   Compiling lazy_static v1.4.0
   Compiling serde_derive v1.0.115
   Compiling serde v1.0.115
   Compiling memchr v2.3.3
   Compiling log v0.4.11
   Compiling proc-macro-hack v0.5.18
   Compiling itoa v0.4.6
   Compiling cc v1.0.59
   Compiling getrandom v0.1.14
   Compiling ryu v1.0.5
   Compiling bitflags v1.2.1
   Compiling byteorder v1.3.4
   Compiling ppv-lite86 v0.2.9
   Compiling siphasher v0.3.3
   Compiling fnv v1.0.7
   Compiling once_cell v1.4.1
   Compiling slab v0.4.2
   Compiling futures-core v0.3.5
   Compiling bytes v0.5.6
   Compiling arc-swap v0.4.7
   Compiling typenum v1.12.0
   Compiling matches v0.1.8
   Compiling pkg-config v0.3.18
   Compiling pin-project-internal v0.4.23
   Compiling pin-project-lite v0.1.7
   Compiling serde_json v1.0.57
   Compiling proc-macro-nested v0.1.6
   Compiling spin v0.5.2
   Compiling untrusted v0.7.1
   Compiling tinyvec v0.3.4
   Compiling either v1.6.0
   Compiling dtoa v0.4.6
   Compiling lexical-core v0.7.4
   Compiling futures-io v0.3.5
   Compiling httparse v1.3.4
   Compiling unicode-segmentation v1.6.0
   Compiling static_assertions v1.1.0
   Compiling maybe-uninit v2.0.0
   Compiling futures-sink v0.3.5
   Compiling unicode-width v0.1.8
   Compiling pin-utils v0.1.0
   Compiling percent-encoding v2.1.0
   Compiling ucd-trie v0.1.3
   Compiling foreign-types-shared v0.1.1
   Compiling maplit v1.0.2
   Compiling openssl v0.10.30
   Compiling arrayvec v0.5.1
   Compiling native-tls v0.2.4
   Compiling regex-syntax v0.6.18
   Compiling try-lock v0.2.3
   Compiling new_debug_unreachable v1.0.4
   Compiling openssl-probe v0.1.2
   Compiling tower-service v0.3.0
   Compiling same-file v1.0.6
   Compiling base64 v0.12.3
   Compiling rayon-core v1.7.1
   Compiling typed-arena v1.7.0
   Compiling precomputed-hash v0.1.1
   Compiling encoding_rs v0.8.23
   Compiling smallvec v1.4.2
   Compiling scopeguard v1.1.0
   Compiling mac v0.1.1
   Compiling utf-8 v0.7.5
   Compiling byte-tools v0.3.1
   Compiling mime v0.3.16
   Compiling nodrop v0.1.14
   Compiling ipnet v2.3.0
   Compiling stable_deref_trait v1.2.0
   Compiling fake-simd v0.1.2
   Compiling hex v0.4.2
   Compiling doc-comment v0.3.3
   Compiling opaque-debug v0.2.3
   Compiling linked-hash-map v0.5.3
   Compiling half v1.6.0
   Compiling thin-slice v0.1.1
   Compiling anyhow v1.0.32
   Compiling number_prefix v0.3.0
   Compiling cpuid-bool v0.1.2
   Compiling termcolor v1.1.0
   Compiling ansi_term v0.11.0
   Compiling humantime v2.0.1
   Compiling vec_map v0.8.2
   Compiling annotate-snippets v0.7.0
   Compiling encode_unicode v0.3.6
   Compiling opaque-debug v0.3.0
   Compiling ego-tree v0.6.2
   Compiling strsim v0.8.0
   Compiling remove_dir_all v0.5.3
   Compiling az v1.0.0
   Compiling shell-escape v0.1.5
   Compiling rprompt v1.0.5
   Compiling human-size v0.4.1
   Compiling tracing-core v0.1.14
   Compiling thread_local v1.0.1
   Compiling hashbrown v0.8.2
   Compiling indexmap v1.5.1
   Compiling crossbeam-utils v0.7.2
   Compiling memoffset v0.5.5
   Compiling crossbeam-epoch v0.8.2
   Compiling num-traits v0.2.12
   Compiling num-integer v0.1.43
   Compiling rayon v1.3.1
   Compiling unicase v2.6.0
   Compiling nom v5.1.2
   Compiling standback v0.2.9
   Compiling generic-array v0.14.4
   Compiling error-chain v0.12.4
   Compiling time v0.2.16
   Compiling proc-macro-error-attr v1.0.4
   Compiling cookie v0.14.2
   Compiling proc-macro-error v1.0.4
   Compiling phf_shared v0.8.0
   Compiling futures-task v0.3.5
   Compiling futures-channel v0.3.5
   Compiling http v0.2.1
   Compiling unicode-bidi v0.3.4
   Compiling itertools v0.9.0
   Compiling unicode-normalization v0.1.13
   Compiling dtoa-short v0.3.2
   Compiling heck v0.3.1
   Compiling getopts v0.2.21
   Compiling textwrap v0.11.0
   Compiling pest v2.1.3
   Compiling foreign-types v0.3.2
   Compiling ring v0.16.15
   Compiling openssl-sys v0.9.58
   Compiling walkdir v2.3.1
   Compiling pretty v0.5.2
   Compiling futf v0.1.4
   Compiling block-padding v0.1.5
   Compiling servo_arc v0.1.1
   Compiling yaml-rust v0.4.4
   Compiling http-body v0.3.1
   Compiling idna v0.2.0
   Compiling pest_meta v2.1.3
   Compiling tendril v0.4.1
   Compiling aho-corasick v0.7.13
   Compiling csv-core v0.1.10
   Compiling fwdansi v1.1.0
   Compiling quote v1.0.7
   Compiling num_cpus v1.13.0
   Compiling iovec v0.1.4
   Compiling net2 v0.2.34
   Compiling signal-hook-registry v1.2.1
   Compiling time v0.1.43
   Compiling socket2 v0.3.12
   Compiling atty v0.2.14
   Compiling termios v0.3.2
   Compiling terminal_size v0.1.13
   Compiling dirs v1.0.5
   Compiling dirs-sys v0.3.5
   Compiling fs2 v0.4.3
   Compiling rpassword v4.0.5
   Compiling tracing v0.1.19
   Compiling want v0.3.0
   Compiling regex-automata v0.1.9
   Compiling fxhash v0.2.1
   Compiling generic-array v0.12.3
   Compiling regex v1.3.9
   Compiling rand_core v0.5.1
   Compiling mio v0.6.22
   Compiling clap v2.33.3
   Compiling term v0.5.2
   Compiling dirs v3.0.1
   Compiling crossbeam-queue v0.2.3
   Compiling mime_guess v2.0.3
   Compiling block-buffer v0.7.3
   Compiling digest v0.8.1
   Compiling block-buffer v0.9.0
   Compiling digest v0.9.0
   Compiling console v0.12.0
   Compiling webpki v0.21.3
   Compiling sct v0.6.0
   Compiling rand_pcg v0.2.1
   Compiling rand_chacha v0.2.2
   Compiling mio-uds v0.6.8
   Compiling pest_generator v2.1.3
   Compiling crossbeam-deque v0.7.3
   Compiling sha2 v0.8.2
   Compiling sha2 v0.9.1
   Compiling webpki-roots v0.19.0
   Compiling rustls v0.18.1
   Compiling abnf v0.6.1
   Compiling rand v0.7.3
   Compiling tokio v0.2.22
   Compiling phf_generator v0.8.0
   Compiling tempfile v3.1.0
   Compiling tokio-util v0.3.1
   Compiling tokio-rustls v0.14.0
   Compiling tokio-tls v0.3.1
   Compiling phf_codegen v0.8.0
   Compiling string_cache_codegen v0.5.1
   Compiling indicatif v0.15.0
   Compiling selectors v0.22.0
   Compiling futures-macro v0.3.5
   Compiling phf_macros v0.8.0
   Compiling cssparser v0.27.2
   Compiling time-macros-impl v0.1.1
   Compiling cssparser-macros v0.6.0
   Compiling html5ever v0.25.1
   Compiling derive_more v0.99.9
   Compiling pest_consume_macros v1.0.5
   Compiling pest_derive v2.1.0
   Compiling strum_macros v0.19.2
   Compiling dhall_proc_macros v0.5.0
   Compiling derivative v2.1.1
   Compiling strum_macros v0.18.0
   Compiling structopt-derive v0.4.9
   Compiling easy-ext v0.2.2
   Compiling phf v0.8.0
   Compiling time-macros v0.1.0
   Compiling pin-project v0.4.23
   Compiling pest_consume v1.0.5
   Compiling strum v0.19.2
   Compiling strum v0.18.0
   Compiling futures-util v0.3.5
   Compiling structopt v0.3.16
   Compiling url v2.1.1
   Compiling bstr v0.2.13
   Compiling string_cache v0.8.0
   Compiling serde_cbor v0.9.0
   Compiling serde_yaml v0.8.13
   Compiling humantime-serde v1.0.0
   Compiling chrono v0.4.15
   Compiling abnf_to_pest v0.5.0
   Compiling h2 v0.2.6
   Compiling serde_urlencoded v0.6.1
   Compiling publicsuffix v1.5.4
   Compiling csv v1.1.3
   Compiling globset v0.4.5
   Compiling markup5ever v0.10.0
   Compiling dhall v0.5.3
   Compiling cookie_store v0.12.0
   Compiling ignore v0.4.16
   Compiling prettytable-rs v0.8.0
   Compiling hyper v0.13.7
   Compiling hyper-rustls v0.21.0
   Compiling hyper-tls v0.4.3
   Compiling scraper v0.12.0
   Compiling reqwest v0.10.7
   Compiling snowchains_core v0.4.2
error: attributes are not yet allowed on `if` expressions
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/snowchains_core-0.4.2/src/web/atcoder.rs:1457:13
     |
1457 |             #[allow(clippy::blocks_in_if_conditions)]
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no associated item named `MAX` found for type `u64` in the current scope
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/snowchains_core-0.4.2/src/web/mod.rs:984:70
    |
984 |                         pb.inc(chunk.len().try_into().unwrap_or(u64::MAX));
    |                                                                      ^^^ associated item not found in `u64`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
            candidate #1: `use lexical_core::util::num::Integer;`
            candidate #2: `use lexical_core::util::num::Float;`
            candidate #3: `use rand::distributions::weighted::alias_method::Weight;`
            candidate #4: `use standback::v1_43::float_v1_43;`
            candidate #5: `use standback::v1_43::int_v1_43;`
help: you are looking for the module in `std`, not the primitive type
    |
984 |                         pb.inc(chunk.len().try_into().unwrap_or(std::u64::MAX));
    |                                                                 ^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `snowchains_core`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `snowchains v0.5.0`, intermediate artifacts can be found at `/tmp/cargo-installtwkIp3`

Caused by:
  build failed

Fails on downloading ARC133-A

状況

% cargo run -- download -s atcoder -c arc133 -p a
   Compiling snowchains_core v0.13.1 (/home/user/snowchains/snowchains_core)
   Compiling snowchains v0.7.0 (/home/user/snowchains)
    Finished dev [unoptimized + debuginfo] target(s) in 32.47s
     Running `target/debug/snowchains download -s atcoder -c arc133 -p a`
GET https://atcoder.jp/contests/arc133/tasks ... 200 OK
GET https://atcoder.jp/contests/arc133/tasks_print ... 200 OK
warning: A: Could not extract the sample cases
A: Saved to /home/user/.snowchains/tests/atcoder/arc133/a.yml (no test cases)

原因

try_extract_samples() 内の以下の部分です。

for (input, output) in &mut samples {
for s in &mut [input, output] {
if !(s.is_empty() || s.ends_with('\n')) {
s.push('\n');
}
if !is_valid_text(s) {
return None;
}
}
}

fn is_valid_text(s: &str) -> bool {
s == "\n"
|| ![' ', '\n'].iter().any(|&c| s.starts_with(c))
&& s.chars().all(|c| {
c.is_ascii() && (c.is_ascii_whitespace() == [' ', '\n'].contains(&c))
})
}

この時、samples の中身は以下のようになっています。

[("5\n2 4 4 1 2\n", "2 1 2\n"), ("3\n1 1 1\n", " \n"), ("5\n1 1 2 3 3\n", "1 1 2\n")]

出力 2 が空白文字で始まっているため、invalid な文字列として認識されます。

問題として正しい出力は空文字列なのですが、実際にページの該当箇所を空文字列としてしまうと表示がダサくなってしまうので、便宜上入れているんだと思います。

空文字列なし:
空文字列なし

空文字列あり:
空文字列あり

解決案

文字列が " \n" だった場合は "" に差し替えれば解決します (典型90 - 002 のサンプルには空白文字のない空文字列のケースがあり、こちらはパースに成功しています)。しかしこれによってホームページ上の誤った箇所を valid とみなして取り込んでしまう恐れがあります。is_valid_text() があるということは過去にそういうことがあったんだろうと想像しているのですが、具体的に懸念されるケースはあるでしょうか?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.