Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu
: ${PROBLEM_ID:=4}
: ${NPROC:=$(nproc)}
: ${JOBS:=$(( NPROC * 4 ))}
: ${COMMIT_ID:=215c8fa}
: ${COMMIT_ID:=e68bc48}

cd
mkdir -p ./problems ./bin
Expand Down
33 changes: 29 additions & 4 deletions src/bin/chokudai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use num::integer::Roots;
use rand::prelude::*;
use std::{env, usize, vec};

struct Config {
flex: f64
}

fn main() {
let timeout: f64 = match std::env::var("TIMEOUT") {
Ok(value) => match value.parse::<f64>() {
Expand All @@ -13,6 +17,15 @@ fn main() {
},
Err(_) => -1.0,
};
let config = &Config {
flex: match std::env::var("CHOKUDAI_FLEX") {
Ok(value) => match value.parse::<f64>() {
Ok(value) => value,
Err(_) => -1.0,
},
Err(_) => -1.0,
},
};

//制限時間の秒数
let timeout = if timeout < 0.0 { 600.0 } else { timeout };
Expand Down Expand Up @@ -290,6 +303,7 @@ fn main() {
let mut v_best = vec![0.0; v];

let ret = get_first_score(
&config,
&input,
&mut first_now,
eps,
Expand Down Expand Up @@ -364,6 +378,7 @@ fn main() {
*/

let ret = get_first_score(
&config,
&input,
&mut now,
eps,
Expand Down Expand Up @@ -464,6 +479,7 @@ fn main() {
for i in &move_vec {
let nextp = now[*i] + vp[move_type];
let add = get_move_score(
config,
false,
&input,
&mut now,
Expand Down Expand Up @@ -491,6 +507,7 @@ fn main() {
for i in &move_vec {
let nextp = now[*i] - vp[move_type];
let add = get_move_score(
config,
false,
&input,
&mut now,
Expand Down Expand Up @@ -549,6 +566,7 @@ fn main() {
best_ans = now.clone();
} else {
next_score = get_first_score(
&config,
&input,
&mut now,
eps,
Expand Down Expand Up @@ -588,6 +606,7 @@ fn main() {
///差分評価を返す関数

fn get_move_score(
config: &Config,
firstflag: bool,
inp: &Input,
now: &mut Vec<P<i64>>,
Expand Down Expand Up @@ -631,8 +650,10 @@ fn get_move_score(
let mut dd = (d2 - d1).abs() as f64;
if dd <= epsd {
dd = 0.0;
} else {
dd += 0.1;
} else if config.flex < 0.0 {
dd += 0.1;
} else {
dd += (dd / epsd - 1.0) * (dd / epsd - 1.0) * config.flex;
}
let add = -dd * derror_value;
dist_error[id] -= add;
Expand All @@ -645,8 +666,10 @@ fn get_move_score(
let mut dd = (d2 - d1).abs() as f64;
if dd <= epsd {
dd = 0.0;
} else {
dd += 0.1;
} else if config.flex < 0.0 {
dd += 0.1;
} else {
dd += (dd / epsd - 1.0) * (dd / epsd - 1.0) * config.flex;
}
let add = -dd * derror_value;
dist_error[id] += add;
Expand Down Expand Up @@ -734,6 +757,7 @@ fn get_move_score(
}

fn get_first_score(
config: &Config,
inp: &Input,
now: &mut Vec<P<i64>>,
eps: i64,
Expand Down Expand Up @@ -769,6 +793,7 @@ fn get_first_score(

for i in 0..n {
get_move_score(
config,
true,
inp,
now,
Expand Down