結果
| 問題 | No.3733 My First Grid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-19 15:26:09 |
| 言語 | Rust (1.97.1 + proconio + num + itertools + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 9,995 bytes |
| 記録 | |
| コンパイル時間 | 1,080 ms |
| コンパイル使用メモリ | 211,744 KB |
| 実行使用メモリ | 25,664 KB |
| 最終ジャッジ日時 | 2026-09-19 15:26:25 |
| 合計ジャッジ時間 | 5,027 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 WA * 1 |
コンパイルメッセージ
warning: unexpected `cfg` condition value: `local`
--> src/main.rs:377:7
|
377 | #[cfg(feature="local")]
| ^^^^^^^^^^^^^^^ help: remove the condition
|
= note: no expected values for `feature`
= help: consider adding `local` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `local`
--> src/main.rs:379:11
|
379 | #[cfg(not(feature="local"))]
| ^^^^^^^^^^^^^^^ help: remove the condition
|
= note: no expected values for `feature`
= help: consider adding `local` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `local`
--> src/main.rs:384:7
|
384 | #[cfg(feature="local")] include!(concat!(env!("HOME"), "/cp/lib/stress_mod.rs"));
| ^^^^^^^^^^^^^^^ help: remove the condition
|
= note: no expected values for `feature`
= help: consider adding `local` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `local`
--> src/main.rs:385:7
|
385 | #[cfg(feature="local")] #[macro_export] macro_rules! input{($($rem:tt)*)=>{rc_input!($($rem)*)}}
| ^^^^^^^^^^^^^^^ help: remove the condition
|
= note: no expected values for `feature`
= help: consider adding `local` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `local`
--> src/main
ソースコード
#![allow(non_snake_case,dead_code,unused_imports)]
use proconio::{*,marker::*};
fn main(){
// stress!(gene,run);
run();
}
fn gene(){
let mut h;
let mut w;
loop{
h=rnd::range(1,10);
w=rnd::range(1,10);
if h*w!=1{
break;
}
}
let k=rnd::range(0,2*h*w-h-w+1);
println!("{} {} {}",h,w,k);
}
fn run(){
input!{
h:usize,
w:usize,
k:usize,
}
let mut ans=vec![vec![0;w];h];
let out=|ans:&Vec<Vec<usize>>|{
for i in 0..h{
for j in 0..w{
if ans[i][j]==1{
print!("#");
} else{
print!(".");
}
}
println!();
}
};
if k==0{
out(&ans);
return;
}
if h==1 || w==1{
if k>1{
println!("-1");
return;
}
if h*w==1 && k==1{
println!("-1");
return;
}
if k==1{
ans[0][0]=1;
}
out(&ans);
return;
}
if k==1{
println!("-1");
return;
}
if k==2{
ans[0][0]=1;
out(&ans);
return;
}
if h==2 || w==2{
if h==2{
if w<k{
println!("-1");
return;
}
for j in 0..k-1{
ans[0][j]=1;
}
} else{
if h<k{
println!("-1");
return;
}
for i in 0..k-1{
ans[i][0]=1;
}
}
out(&ans);
return;
}
let mut ps=vec![];
ps.push(P::new(0,1));
for j in (1..w).step_by(4){
if j+2==w-1{
for i in (1..h-1).step_by(4){
ps.push(P::new(i,j));
ps.push(P::new(i,j+1));
if i+1==h-1{
break;
}
ps.push(P::new(i+1,j+1));
if i+2==h-1{
break;
}
ps.push(P::new(i+2,j+1));
ps.push(P::new(i+2,j));
if i+3==h-1{
break;
}
ps.push(P::new(i+3,j));
}
break;
}
for i in 1..h-1{
ps.push(P::new(i,j));
}
if j+1==w-1{
break;
}
ps.push(P::new(h-2,j+1));
if j+4==w-1{
for i in (1..h-1).rev().step_by(4){
ps.push(P::new(i,j+2));
ps.push(P::new(i,j+2+1));
if i-1==0{
break;
}
ps.push(P::new(i-1,j+2+1));
if i-2==0{
break;
}
ps.push(P::new(i-2,j+2+1));
ps.push(P::new(i-2,j+2));
if i-3==0{
break;
}
ps.push(P::new(i-3,j+2));
}
break;
}
for i in (1..h-1).rev(){
ps.push(P::new(i,j+2));
}
if j+3==w-1{
break;
}
ps.push(P::new(1,j+3));
}
let mut d=vec![vec![!0;w];h];
for (i,&p) in ps.iter().enumerate(){
d[p]=i;
}
if k%2==0{
assert!(k>=2);
ps.remove(0);
let nes=(k-2)/2;
if ps.len()<nes{
println!("-1");
return;
}
for &p in ps.iter().take(nes){
ans[p]=1;
}
} else{
assert!(k>=3);
let nes=(k-1)/2;
if ps.len()<nes{
println!("-1");
return;
}
for &p in ps.iter().take(nes){
ans[p]=1;
}
}
out(&ans);
}
use itertools::*;
trait ChangeMinMax:Copy+PartialOrd{
fn chmin(&mut self,a:Self)->bool{
*self>a && {
*self=a;
true
}
}
fn chmax(&mut self,a:Self)->bool{
*self<a && {
*self=a;
true
}
}
}
impl<T:Copy+PartialOrd> ChangeMinMax for T{}
// library: https://github.com/rhoo19937/cp-lib
// LURD
const DD:[P;4]=[P{i:0,j:!0},P{i:!0,j:0},P{i:0,j:1},P{i:1,j:0}];
const DX:[P;8]=[P{i:0,j:!0},P{i:!0,j:!0},P{i:!0,j:0},P{i:!0,j:1},P{i:0,j:1},P{i:1,j:1},P{i:1,j:0},P{i:1,j:!0}];
#[derive(Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Hash,Default)]
struct P{
i:usize,
j:usize,
}
impl P{
fn new(i:usize,j:usize)->P{
P{i,j}
}
fn in_range(self,h:usize,w:usize)->bool{
self.i<h && self.j<w
}
fn id(self,w:usize)->usize{
self.i*w+self.j
}
fn from(id:usize,w:usize)->P{
P::new(id/w,id%w)
}
fn manh(self,p:P)->usize{
let abs_diff=|a,b|(a as i64-b as i64).abs() as usize;
abs_diff(self.i,p.i)+abs_diff(self.j,p.j)
}
fn parity(self)->bool{
(self.i^self.j)%2==1
}
fn dir(self,p:P)->usize{
if self.i==p.i{
if self.j-1==p.j{
0
} else{
assert!(self.j+1==p.j);
2
}
} else{
if self.i-1==p.i{
1
} else{
assert!(self.i+1==p.i);
3
}
}
}
}
impl std::fmt::Debug for P{
fn fmt(&self,f:&mut std::fmt::Formatter)->std::fmt::Result{
write!(f,"({}, {})",self.i,self.j)
}
}
impl std::ops::Add for P{
type Output=P;
fn add(self,a:P)->P{
P{
i:self.i+a.i,
j:self.j+a.j,
}
}
}
impl std::ops::Sub for P{
type Output=P;
fn sub(self,a:P)->P{
P{
i:self.i-a.i,
j:self.j-a.j,
}
}
}
impl std::ops::Mul<usize> for P{
type Output=P;
fn mul(self,a:usize)->P{
P{
i:self.i*a,
j:self.j*a,
}
}
}
impl std::ops::Div<usize> for P{
type Output=P;
fn div(self,a:usize)->P{
P{
i:self.i/a,
j:self.j/a,
}
}
}
impl std::ops::Neg for P{
type Output=P;
fn neg(self)->P{
P{
i:self.i.wrapping_neg(),
j:self.j.wrapping_neg(),
}
}
}
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!(usize,MulAssign,mul_assign,*);
impl_p_ops!(usize,DivAssign,div_assign,/);
macro_rules! impl_p_index{
($t:ty)=>{
impl<T:std::ops::Index<usize>> std::ops::Index<P> for $t{
type Output=T::Output;
fn index(&self,idx:P)->&T::Output{
&self[idx.i][idx.j]
}
}
impl<T:std::ops::IndexMut<usize>> std::ops::IndexMut<P> for $t{
fn index_mut(&mut self,idx:P)->&mut T::Output{
&mut self[idx.i][idx.j]
}
}
}
}
impl_p_index!([T]);
impl_p_index!(Vec<T>);
fn iterp(h:usize,w:usize)->impl Iterator<Item=P>{
(0..h).map(move|i|(0..w).map(move|j|P::new(i,j))).flatten()
}
#[cfg(feature="local")]
include!(concat!(env!("HOME"), "/cp/lib/debug_mod.rs"));
#[cfg(not(feature="local"))]
#[macro_export]macro_rules! debug{($($t:tt)*)=>{}}
#[cfg(feature="local")] include!(concat!(env!("HOME"), "/cp/lib/stress_mod.rs"));
#[cfg(feature="local")] #[macro_export] macro_rules! input{($($rem:tt)*)=>{rc_input!($($rem)*)}}
#[cfg(feature="local")] #[macro_export] macro_rules! print{($($rem:tt)*)=>{rc_print!($($rem)*)}}
#[cfg(feature="local")] #[macro_export] macro_rules! println{($($rem:tt)*)=>{rc_println!($($rem)*)}}
#[cfg(feature="local")] #[macro_export] macro_rules! eprint{($($rem:tt)*)=>{rc_eprint!($($rem)*)}}
#[cfg(feature="local")] #[macro_export] macro_rules! eprintln{($($rem:tt)*)=>{rc_eprintln!($($rem)*)}}
#[cfg(not(feature="local"))] #[macro_export] macro_rules! stress{($($rem:tt)*)=>{}}
#[cfg(not(feature="local"))] #[macro_export] macro_rules! istress{($($rem:tt)*)=>{}}
#[allow(unused)]
mod rnd{
static mut X2:u32=12345;
static mut X3:u32=0xcafef00d;
static mut C_X1:u64=0xd15ea5e5<<32|23456;
pub fn set_seed(seed:u64){
unsafe{
C_X1^=seed as u64;
}
}
pub fn next()->u32{
unsafe{
let x=X3 as u64*3487286589;
let ret=(X3^X2)+(C_X1 as u32^(x>>32) as u32);
X3=X2;
X2=C_X1 as u32;
C_X1=x+(C_X1>>32);
ret
}
}
pub fn next64()->u64{
(next() as u64)<<32|next() as u64
}
pub fn nextf()->f64{
f64::from_bits(0x3ff0000000000000|(next() as u64)<<20)-1.
}
pub fn get(n:usize)->usize{
assert!(0<n && n<=u32::MAX as usize);
next() as usize*n>>32
}
pub fn range(a:usize,b:usize)->usize{
assert!(a<b);
get(b-a)+a
}
pub fn range_skip(a:usize,b:usize,skip:usize)->usize{
assert!(a<=skip && skip<b);
let n=range(a,b-1);
n+(skip<=n) as usize
}
pub fn rangei(a:i64,b:i64)->i64{
assert!(a<b);
get((b-a) as usize) as i64+a
}
pub fn shuffle<T>(a:&mut [T]){
for i in (1..a.len()).rev(){
a.swap(i,get(i+1));
}
}
pub fn shuffle_iter<T:Copy>(a:&mut [T])->impl Iterator<Item=T>{
(0..a.len()).rev().map(|i|{
a.swap(i,get(i+1));
a[i]
})
}
}
#[allow(unused)]
trait RandomChoice{
type Output;
fn choice(&self)->&Self::Output;
}
impl<T> RandomChoice for [T]{
type Output=T;
fn choice(&self)->&T{
&self[rnd::get(self.len())]
}
}