Comments (4)
(M-1-2+1) as usize
を単純にusizeのM-1-2+1とすると、underflowになってしまうので、そこは考えなければ。
from atcoder-tools.
use io::*;
use std::*;
const MOD: i64 = 123;
const YES: &'static str = "yes";
const NO: &'static str = "NO";
fn solve(N: i64, M: i64, H: Vec<Vec<String>>, A: Vec<i64>, B: Vec<f64>, Q: i64, X: Vec<i64>) {}
fn main() {
let con = read_string();
let mut scanner = Scanner::new(&con);
let N: i64 = scanner.next();
let M: i64 = scanner.next();
let H: Vec<Vec<String>> = (0..(N - 2 + 1) as usize)
.map(|_| {
(0..(M - 1 - 2 + 1) as usize)
.map(|_| scanner.next())
.collect::<Vec<_>>()
})
.collect::<Vec<_>>();
let mut A: Vec<i64> = vec![0i64; (N - 2 + 1) as usize];
let mut B: Vec<f64> = vec![0f64; (N - 2 + 1) as usize];
for i in 0..(N - 2 + 1) as usize {
A[i] = scanner.next();
B[i] = scanner.next();
}
let Q: i64 = scanner.next();
let X: Vec<i64> = (0..(M + Q) as usize)
.map(|_| scanner.next())
.collect::<Vec<_>>();
// In order to avoid potential stack overflow, spawn a new thread.
let stack_size = 104_857_600; // 100 MB
let thd = std::thread::Builder::new().stack_size(stack_size);
thd.spawn(move || solve(N, M, H, A, B, Q, X))
.unwrap()
.join()
.unwrap();
}
pub mod io {
use std;
use std::str::FromStr;
pub struct Scanner<'a> {
iter: std::str::SplitWhitespace<'a>,
}
impl<'a> Scanner<'a> {
pub fn new(s: &'a str) -> Scanner<'a> {
Scanner {
iter: s.split_whitespace(),
}
}
pub fn next<T: FromStr>(&mut self) -> T {
let s = self.iter.next().unwrap();
if let Ok(v) = s.parse::<T>() {
v
} else {
panic!("Parse error")
}
}
pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
let n: usize = self.next();
self.next_vec(n)
}
pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
(0..n).map(|_| self.next()).collect()
}
}
pub fn read_string() -> String {
use std::io::Read;
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).unwrap();
s
}
pub fn read_line() -> String {
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
s.trim_right().to_owned()
}
}
mutを消すとこうなる、ただvectorはcollectするより最初に容量確保する今の実装の方が速いかも。
from atcoder-tools.
Rustわからないんですが、途中式で負数が出てくるとエラーになってしまいますか?
だとしたら多分アンダーフローとかはSymPy等導入してきちんと式整理したほうが良いという提案をkimiyukiさんから受けたので、検討します。
from atcoder-tools.
そうです、usizeの計算中にマイナスになるとabortされます。
Issue立てたものの、いつ取り掛かれるかわからないので、私の方は気にせず、sympyが必要になれば導入してください。
from atcoder-tools.
Related Issues (20)
- python でのsubmit時のlanguage_number取得時のerror
- submit時のsave_no_session_cacheが逆になっている
- Merge remaining pending changes to be released branched from 1.1.5
- TLE になるケースをテストするとクラッシュする
- 開発フローを明らかにして極力自動化する + Python3.5サポート廃止
- genコマンドでコード生成する際、ファイルがすでにある場合にスキップするオプションが欲しい HOT 3
- 対応言語を自動でREADMEに反映
- Universal code generatorのテンプレートを指定したい HOT 4
- atcoder-tools loginが欲しい
- test や submit の --dir に相対パスを指定すると実行ファイルの実行に失敗する
- submitコマンドが終了コード255で終了する
- input_part_prefixが使われていない
- submit コマンドにも lang オプションが欲しい HOT 3
- Go言語でatcoder-tools testを実行するとエラーで失敗する
- "soft_unicode" is not supported in latest markupsafe HOT 2
- Tampemonkey用Userscriptのリンク切れ
- gen コマンドでコンテストの指定にURLを使えるようにする
- 言語アップデートでの提出の表記が変わった HOT 2
- submitコマンド実行終了時、提出結果ページをブラウザで開く HOT 1
- atcoderのサイトではacになるコードが"atcoder-tools test" で通らないです。
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atcoder-tools.