Submission #68092063
Source Code Expand
#![allow(non_snake_case)]
// てきとうに、グラフを作って、焼きなましでいい感じの割当てを決めるやつを作る
// グラフはある程度幅がないとだめ?
fn main(){
let input=get_input();
let goal=(0..input.n).collect_vec();
let root=Goal(0);
let via=vec![(!0,Null,Null);input.m];
output_ans(&goal,root,&via);
}
#[derive(Clone,Copy,PartialEq,Eq,Debug)]
enum V{
Null,
Via(usize),
Goal(usize),
}
use V::*;
fn output_ans(goal:&[usize],root:V,via:&[(usize,V,V)]){
let input=get_input();
println!("{}",goal.iter().join(" "));
let id=|v|{
match v{
Null=>!0,
Via(a)=>input.n+a,
Goal(a)=>a,
}
};
println!("{}",id(root));
for &(a,b,c) in via{
if a==!0{
println!("-1");
} else{
println!("{} {} {}",a,id(b),id(c));
}
}
}
use itertools::*;
// use delaunator::*;
const MAX:i64=1e4 as i64;
struct Input{
n:usize,
m:usize,
k:usize,
start:P,
goal:Vec<P>,
via:Vec<P>,
prob:Vec<Vec<f64>>,
}
static_data!{
get_input:Input|{
proconio::input!{
n:usize,
m:usize,
k:usize,
dp:[(i64,i64);n],
sp:[(i64,i64);m],
prob:[[f64;n];k],
}
let start=P::new(0,MAX/2);
let goal=dp.iter().map(|&(x,y)|P::new(x,y)).collect_vec();
let via=sp.iter().map(|&(x,y)|P::new(x,y)).collect_vec();
Input{n,m,k,start,goal,via,prob}
}
}
#[macro_export]
macro_rules! static_data{
($a:ident:$t:ty|$e:expr)=>{
fn $a()->&'static $t{
use std::sync::OnceLock;
#[allow(non_upper_case_globals)]
static $a:OnceLock<$t>=OnceLock::new();
$a.get_or_init(||$e)
}
}
}
#[derive(Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Hash)]
struct P{
x:i64,
y:i64,
}
impl P{
fn new(x:i64,y:i64)->P{
P{x,y}
}
fn in_range(self)->bool{
self.x<=MAX as i64 && self.y<=MAX as i64
}
fn det(self,p:P)->i64{
self.x*p.y-self.y*p.x
}
fn dot(self,p:P)->i64{
self.x*p.x+self.y*p.y
}
fn abs2(self)->i64{
self.dot(self)
}
fn manh(self,p:P)->i64{
(self.x-p.x).abs()+(self.x-p.y).abs()
}
}
impl std::fmt::Debug for P{
fn fmt(&self,f:&mut std::fmt::Formatter)->std::fmt::Result{
write!(f,"({}, {})",self.x,self.y)
}
}
impl std::ops::Add for P{
type Output=P;
fn add(self,a:P)->P{
P{
x:self.x+a.x,
y:self.y+a.y,
}
}
}
impl std::ops::Sub for P{
type Output=P;
fn sub(self,a:P)->P{
P{
x:self.x-a.x,
y:self.y-a.y,
}
}
}
impl std::ops::Mul<i64> for P{
type Output=P;
fn mul(self,a:i64)->P{
P{
x:self.x*a,
y:self.y*a,
}
}
}
impl std::ops::Div<i64> for P{
type Output=P;
fn div(self,a:i64)->P{
P{
x:self.x/a,
y:self.y/a,
}
}
}
impl std::ops::Neg for P{
type Output=P;
fn neg(self)->P{
P{
x:-self.x,
y:-self.y,
}
}
}
macro_rules! impl_p_ops{
($t:ty,$assign_trait:ident,$assign_func:ident,$op:tt)=>{
impl std::ops::$assign_trait<$t> for P{
fn $assign_func(&mut self,a:$t){
*self=*self $ op a;
}
}
}
}
impl_p_ops!(P,AddAssign,add_assign,+);
impl_p_ops!(P,SubAssign,sub_assign,-);
impl_p_ops!(i64,MulAssign,mul_assign,*);
impl_p_ops!(i64,DivAssign,div_assign,/);
// 線分p0p1とq0q1が、共有点を持つかどうか
fn segments_intersect(p0:P,p1:P,q0:P,q1:P)->bool{
let sign=|x:i64|{
if x>0{
1
} else if x<0{
-1
} else{
0
}
};
let orient=|a:P,b:P,c:P|sign((b-a).det(c-a));
if p0.x.max(p1.x) < q0.x.min(q1.x) || q0.x.max(q1.x) < p0.x.min(p1.x)
|| p0.y.max(p1.y) < q0.y.min(q1.y) || q0.y.max(q1.y) < p0.y.min(p1.y)
{
return false;
}
let o0=orient(p0,p1,q0);
let o1=orient(p0,p1,q1);
let o2=orient(q0,q1,p0);
let o3=orient(q0,q1,p1);
o0*o1<=0 && o2*o3<=0
}
// include!("../../delaunator.rs");
Submission Info
Submission Time |
|
Task |
A - Probabilistic Waste Sorting |
User |
rhoo |
Language |
Rust (rustc 1.70.0) |
Score |
45213628817 |
Code Size |
4598 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
2172 KiB |
Compile Error
warning: variant `Via` is never constructed
--> src/main.rs:24:5
|
22 | enum V{
| - variant in this enum
23 | Null,
24 | Via(usize),
| ^^^
|
= note: `V` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
warning: fields `k`, `start`, `goal`, `via`, and `prob` are never read
--> src/main.rs:66:5
|
63 | struct Input{
| ----- fields in this struct
...
66 | k:usize,
| ^
67 | start:P,
| ^^^^^
68 | goal:Vec<P>,
| ^^^^
69 | via:Vec<P>,
| ^^^
70 | prob:Vec<Vec<f64>>,
| ^^^^
warning: methods `in_range`, `det`, `dot`, `abs2`, and `manh` are never used
--> src/main.rs:122:8
|
117 | impl P{
| ------ methods in this implementation
...
122 | fn in_range(self)->bool{
| ^^^^^^^^
...
126 | fn det(self,p:P)->i64{
| ^^^
...
130 | fn dot(self,p:P)->i64{
| ^^^
...
134 | fn abs2(self)->i64{
| ^^^^
...
138 | fn manh(self,p:P)->i64{
| ^^^^
warning: function `segments_intersect` is never used
--> src/main.rs:216:4
|
216 | fn segments_intersect(p0:P,p1:P,q0:P,q1:P)->bool{
| ^^^^^^^^^^^^^^^^^^
Judge Result
Set Name |
test_ALL |
Score / Max Score |
45213628817 / 50000000000 |
Status |
|
Set Name |
Test Cases |
test_ALL |
test_0000.txt, test_0001.txt, test_0002.txt, test_0003.txt, test_0004.txt, test_0005.txt, test_0006.txt, test_0007.txt, test_0008.txt, test_0009.txt, test_0010.txt, test_0011.txt, test_0012.txt, test_0013.txt, test_0014.txt, test_0015.txt, test_0016.txt, test_0017.txt, test_0018.txt, test_0019.txt, test_0020.txt, test_0021.txt, test_0022.txt, test_0023.txt, test_0024.txt, test_0025.txt, test_0026.txt, test_0027.txt, test_0028.txt, test_0029.txt, test_0030.txt, test_0031.txt, test_0032.txt, test_0033.txt, test_0034.txt, test_0035.txt, test_0036.txt, test_0037.txt, test_0038.txt, test_0039.txt, test_0040.txt, test_0041.txt, test_0042.txt, test_0043.txt, test_0044.txt, test_0045.txt, test_0046.txt, test_0047.txt, test_0048.txt, test_0049.txt |
Case Name |
Status |
Exec Time |
Memory |
test_0000.txt |
AC |
1 ms |
1972 KiB |
test_0001.txt |
AC |
1 ms |
1972 KiB |
test_0002.txt |
AC |
1 ms |
2080 KiB |
test_0003.txt |
AC |
1 ms |
1840 KiB |
test_0004.txt |
AC |
1 ms |
2032 KiB |
test_0005.txt |
AC |
1 ms |
2064 KiB |
test_0006.txt |
AC |
1 ms |
1988 KiB |
test_0007.txt |
AC |
1 ms |
1988 KiB |
test_0008.txt |
AC |
1 ms |
1916 KiB |
test_0009.txt |
AC |
1 ms |
2056 KiB |
test_0010.txt |
AC |
1 ms |
2008 KiB |
test_0011.txt |
AC |
1 ms |
2052 KiB |
test_0012.txt |
AC |
1 ms |
2024 KiB |
test_0013.txt |
AC |
1 ms |
2156 KiB |
test_0014.txt |
AC |
1 ms |
1972 KiB |
test_0015.txt |
AC |
1 ms |
2144 KiB |
test_0016.txt |
AC |
1 ms |
2012 KiB |
test_0017.txt |
AC |
1 ms |
1932 KiB |
test_0018.txt |
AC |
1 ms |
2172 KiB |
test_0019.txt |
AC |
1 ms |
2116 KiB |
test_0020.txt |
AC |
1 ms |
1968 KiB |
test_0021.txt |
AC |
1 ms |
1860 KiB |
test_0022.txt |
AC |
1 ms |
2140 KiB |
test_0023.txt |
AC |
1 ms |
2032 KiB |
test_0024.txt |
AC |
1 ms |
2136 KiB |
test_0025.txt |
AC |
1 ms |
1892 KiB |
test_0026.txt |
AC |
1 ms |
1992 KiB |
test_0027.txt |
AC |
1 ms |
1992 KiB |
test_0028.txt |
AC |
1 ms |
2060 KiB |
test_0029.txt |
AC |
1 ms |
1932 KiB |
test_0030.txt |
AC |
1 ms |
1948 KiB |
test_0031.txt |
AC |
1 ms |
1976 KiB |
test_0032.txt |
AC |
1 ms |
2020 KiB |
test_0033.txt |
AC |
1 ms |
1960 KiB |
test_0034.txt |
AC |
1 ms |
1956 KiB |
test_0035.txt |
AC |
1 ms |
1956 KiB |
test_0036.txt |
AC |
1 ms |
2052 KiB |
test_0037.txt |
AC |
1 ms |
2096 KiB |
test_0038.txt |
AC |
1 ms |
1992 KiB |
test_0039.txt |
AC |
1 ms |
1996 KiB |
test_0040.txt |
AC |
1 ms |
1984 KiB |
test_0041.txt |
AC |
1 ms |
2060 KiB |
test_0042.txt |
AC |
1 ms |
2004 KiB |
test_0043.txt |
AC |
1 ms |
1988 KiB |
test_0044.txt |
AC |
1 ms |
2000 KiB |
test_0045.txt |
AC |
1 ms |
1976 KiB |
test_0046.txt |
AC |
1 ms |
1992 KiB |
test_0047.txt |
AC |
1 ms |
2020 KiB |
test_0048.txt |
AC |
1 ms |
1880 KiB |
test_0049.txt |
AC |
1 ms |
2160 KiB |