QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#284511#7940. Impossible Numbersucup-team635#AC ✓139ms15196kbRust7.7kb2023-12-16 13:44:202023-12-16 13:44:21

Judging History

你现在查看的是最新测评结果

  • [2023-12-17 13:41:15]
  • hack成功,自动添加数据
  • (/hack/501)
  • [2023-12-16 13:44:21]
  • 评测
  • 测评结果:AC
  • 用时:139ms
  • 内存:15196kb
  • [2023-12-16 13:44:20]
  • 提交

answer

use std::collections::*;
use std::io::Write;

type Map<K, V> = BTreeMap<K, V>;
type Set<T> = BTreeSet<T>;
type Deque<T> = VecDeque<T>;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [[usize; 6]; n],
    }
    const P: usize = 10;
    let mut cnt = vec![0u8; 1 << P];
    for a in a {
        let mut bit = 0;
        for a in a {
            bit |= 1 << a;
        }
        for (i, c) in cnt.iter_mut().enumerate() {
            if i & bit > 0 {
                *c += 1;
            }
        }
    }
    let min = *cnt[1..].iter().min().unwrap();
    let mut ans: Vec<Vec<u8>> = vec![];
    let mut dp: Vec<[u8; 10]> = vec![];
    for c in (min + 1).. {
        for (i, cnt) in cnt.iter().enumerate().skip(1) {
            if *cnt + 1 != c {
                continue;
            }
            let k = i.count_ones();
            let v = (0..P).filter(|p| i >> *p & 1 == 1).collect::<Vec<_>>();
            let mut a = vec![0; c as usize];
            a.extend((1..k).map(|_| 1));
            while {
                let mut state = [0; 10];
                let mut s = 0;
                let mut x = 0;
                for a in a.iter() {
                    if *a == 0 {
                        s += 1;
                    } else {
                        state[v[x]] = s;
                        s = 0;
                        x += 1;
                    }
                }
                state[v[x]] = s;
                dp.push(state);
                a.next_permutation()
            } {}
        }
        dp.sort();
        dp.dedup();
        use std::cmp::*;
        let mut h = std::collections::BinaryHeap::new();
        for state in dp.iter() {
            let mut a = Vec::with_capacity(c as usize);
            for (i, &s) in state.iter().enumerate() {
                a.extend((0..s).map(|_| i as u8));
            }
            if let Some(x) = a.iter().position(|a| *a > 0) {
                a[..=x].rotate_right(1);
                h.push(Reverse(a));
            }
        }
        while let Some(Reverse(mut a)) = h.pop() {
            ans.push(a.clone());
            if ans.len() == m {
                break;
            }
            if a.next_permutation() {
                h.push(Reverse(a));
            }
        }
        if ans.len() == m {
            break;
        }
        let mut next = vec![];
        for state in dp {
            for i in 0..10 {
                let mut s = state;
                s[i] += 1;
                next.push(s);
            }
        }
        dp = next;
    }
    ans.truncate(m);
    use util::*;
    println!("{}", ans.iter().map(|a| a.iter().join("")).join(" "));
}

// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// ---------- end input macro ----------
// ---------- begin super slice ----------
pub trait SuperSlice {
    type Item;
    fn lower_bound(&self, key: &Self::Item) -> usize
    where
        Self::Item: Ord;
    fn lower_bound_by<F>(&self, f: F) -> usize
    where
        F: FnMut(&Self::Item) -> std::cmp::Ordering;
    fn lower_bound_by_key<K, F>(&self, key: &K, f: F) -> usize
    where
        K: Ord,
        F: FnMut(&Self::Item) -> K;
    fn upper_bound(&self, key: &Self::Item) -> usize
    where
        Self::Item: Ord;
    fn upper_bound_by<F>(&self, f: F) -> usize
    where
        F: FnMut(&Self::Item) -> std::cmp::Ordering;
    fn upper_bound_by_key<K, F>(&self, key: &K, f: F) -> usize
    where
        K: Ord,
        F: FnMut(&Self::Item) -> K;
    fn next_permutation(&mut self) -> bool
    where
        Self::Item: Ord;
    fn next_permutation_by<F>(&mut self, f: F) -> bool
    where
        F: FnMut(&Self::Item, &Self::Item) -> std::cmp::Ordering;
    fn prev_permutation(&mut self) -> bool
    where
        Self::Item: Ord;
}

impl<T> SuperSlice for [T] {
    type Item = T;
    fn lower_bound(&self, key: &Self::Item) -> usize
    where
        T: Ord,
    {
        self.lower_bound_by(|p| p.cmp(key))
    }
    fn lower_bound_by<F>(&self, mut f: F) -> usize
    where
        F: FnMut(&Self::Item) -> std::cmp::Ordering,
    {
        self.binary_search_by(|p| f(p).then(std::cmp::Ordering::Greater))
            .unwrap_err()
    }
    fn lower_bound_by_key<K, F>(&self, key: &K, mut f: F) -> usize
    where
        K: Ord,
        F: FnMut(&Self::Item) -> K,
    {
        self.lower_bound_by(|p| f(p).cmp(key))
    }
    fn upper_bound(&self, key: &Self::Item) -> usize
    where
        T: Ord,
    {
        self.upper_bound_by(|p| p.cmp(key))
    }
    fn upper_bound_by<F>(&self, mut f: F) -> usize
    where
        F: FnMut(&Self::Item) -> std::cmp::Ordering,
    {
        self.binary_search_by(|p| f(p).then(std::cmp::Ordering::Less))
            .unwrap_err()
    }
    fn upper_bound_by_key<K, F>(&self, key: &K, mut f: F) -> usize
    where
        K: Ord,
        F: FnMut(&Self::Item) -> K,
    {
        self.upper_bound_by(|p| f(p).cmp(key))
    }
    fn next_permutation(&mut self) -> bool
    where
        T: Ord,
    {
        self.next_permutation_by(|a, b| a.cmp(b))
    }
    fn next_permutation_by<F>(&mut self, mut f: F) -> bool
    where
        F: FnMut(&Self::Item, &Self::Item) -> std::cmp::Ordering,
    {
        use std::cmp::Ordering::*;
        if let Some(x) = self.windows(2).rposition(|a| f(&a[0], &a[1]) == Less) {
            let y = self.iter().rposition(|b| f(&self[x], b) == Less).unwrap();
            self.swap(x, y);
            self[(x + 1)..].reverse();
            true
        } else {
            self.reverse();
            false
        }
    }
    fn prev_permutation(&mut self) -> bool
    where
        T: Ord,
    {
        self.next_permutation_by(|a, b| a.cmp(b).reverse())
    }
}
// ---------- end super slice ----------

mod util {
    pub trait Join {
        fn join(self, sep: &str) -> String;
    }

    impl<T, I> Join for I
    where
        I: Iterator<Item = T>,
        T: std::fmt::Display,
    {
        fn join(self, sep: &str) -> String {
            let mut s = String::new();
            use std::fmt::*;
            for (i, v) in self.enumerate() {
                if i > 0 {
                    write!(&mut s, "{}", sep).ok();
                }
                write!(&mut s, "{}", v).ok();
            }
            s
        }
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1988kb

input:

2 3
1 8 7 0 6 2
1 2 5 4 9 3

output:

33 34 35

result:

ok single line: '33 34 35'

Test #2:

score: 0
Accepted
time: 1ms
memory: 2300kb

input:

1 10
1 5 2 2 6 4

output:

3 7 8 9 10 11 12 13 14 15

result:

ok single line: '3 7 8 9 10 11 12 13 14 15'

Test #3:

score: 0
Accepted
time: 0ms
memory: 2076kb

input:

4 10
1 5 7 1 2 4
0 1 5 8 9 4
3 5 2 2 7 8
6 1 7 0 2 2

output:

33 66 99 133 166 199 233 266 299 303

result:

ok single line: '33 66 99 133 166 199 233 266 299 303'

Test #4:

score: 0
Accepted
time: 0ms
memory: 2284kb

input:

5 10
5 9 4 8 3 3
1 1 9 2 8 9
6 3 3 0 2 1
2 6 0 3 6 4
3 6 4 2 9 4

output:

7 17 27 37 47 55 57 67 70 71

result:

ok single line: '7 17 27 37 47 55 57 67 70 71'

Test #5:

score: 0
Accepted
time: 0ms
memory: 2084kb

input:

5 10
8 7 1 4 8 9
2 5 0 1 0 1
9 5 5 3 9 7
6 0 0 2 3 1
1 0 0 4 9 3

output:

66 88 166 188 222 226 262 266 288 366

result:

ok single line: '66 88 166 188 222 226 262 266 288 366'

Test #6:

score: 0
Accepted
time: 0ms
memory: 2076kb

input:

5 10
6 8 7 7 0 0
0 5 1 9 4 1
5 9 6 9 5 4
0 4 6 9 1 6
2 8 7 4 4 0

output:

3 13 22 23 30 31 32 33 34 35

result:

ok single line: '3 13 22 23 30 31 32 33 34 35'

Test #7:

score: 0
Accepted
time: 1ms
memory: 2220kb

input:

5 1000
0 4 1 3 9 6
9 6 2 1 8 6
5 3 0 7 7 3
0 2 8 0 8 4
2 4 1 2 9 7

output:

55 155 255 333 335 353 355 455 505 515 525 533 535 545 550 551 552 553 554 555 556 557 558 559 565 575 577 585 595 655 666 755 757 775 777 855 888 955 1055 1111 1116 1119 1155 1161 1166 1169 1191 1196 1199 1255 1333 1335 1353 1355 1455 1505 1515 1525 1533 1535 1545 1550 1551 1552 1553 1554 1555 1556...

result:

ok single line: '55 155 255 333 335 353 355 455...0 10053 10055 10111 10116 10119'

Test #8:

score: 0
Accepted
time: 4ms
memory: 2760kb

input:

5 10000
1 4 7 5 6 0
2 3 8 4 9 0
1 2 8 8 3 0
7 9 9 7 2 9
4 7 1 9 3 6

output:

55 155 255 355 455 505 515 525 535 545 550 551 552 553 554 555 556 557 558 559 565 566 575 585 595 655 656 665 666 755 855 888 955 1055 1111 1115 1116 1151 1155 1156 1161 1165 1166 1255 1355 1455 1505 1511 1515 1516 1525 1535 1545 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1561 1565 1566 1575...

result:

ok single line: '55 155 255 355 455 505 515 525...6 45507 45508 45509 45510 45511'

Test #9:

score: 0
Accepted
time: 3ms
memory: 2832kb

input:

6 10000
0 1 3 2 4 7
7 6 4 8 7 9
5 5 7 2 3 9
8 4 6 1 6 4
2 4 9 9 0 7
1 2 3 3 2 0

output:

55 155 255 355 455 505 515 525 535 545 550 551 552 553 554 555 556 557 558 559 565 575 585 595 655 666 668 686 688 755 855 866 868 886 888 955 1055 1111 1155 1255 1355 1455 1505 1515 1525 1535 1545 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1565 1575 1585 1595 1655 1666 1668 1686 1688 1755 18...

result:

ok single line: '55 155 255 355 455 505 515 525...6 66847 66848 66849 66850 66851'

Test #10:

score: 0
Accepted
time: 1ms
memory: 2164kb

input:

7 1000
5 2 1 6 3 7
7 9 8 1 8 1
8 7 2 0 6 2
3 8 6 0 5 1
8 8 3 7 0 8
1 0 6 3 5 6
6 7 5 0 9 1

output:

4 14 24 34 40 41 42 43 44 45 46 47 48 49 54 64 74 84 94 104 114 124 134 140 141 142 143 144 145 146 147 148 149 154 164 174 184 194 204 214 222 224 234 240 241 242 243 244 245 246 247 248 249 254 264 274 284 294 304 314 324 334 340 341 342 343 344 345 346 347 348 349 354 364 374 384 394 400 401 402 ...

result:

ok single line: '4 14 24 34 40 41 42 43 44 45 4...3 3474 3475 3476 3477 3478 3479'

Test #11:

score: 0
Accepted
time: 1ms
memory: 2216kb

input:

8 1000
3 8 1 9 7 6
6 5 2 1 8 9
3 8 7 9 2 3
0 5 7 7 7 3
2 9 0 4 2 9
2 7 5 0 5 3
5 9 2 7 0 8
8 3 1 3 0 5

output:

44 144 244 344 404 414 424 434 440 441 442 443 444 445 446 447 448 449 454 464 474 484 494 544 644 666 744 844 944 1044 1111 1116 1144 1161 1166 1244 1344 1404 1414 1424 1434 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1454 1464 1474 1484 1494 1544 1611 1616 1644 1661 1666 1744 1844 1944 2044 ...

result:

ok single line: '44 144 244 344 404 414 424 434...4 14540 14541 14542 14543 14544'

Test #12:

score: 0
Accepted
time: 3ms
memory: 2656kb

input:

9 10000
0 8 4 7 2 8
7 8 3 1 8 4
1 2 6 5 4 9
1 1 3 0 8 2
6 3 0 2 4 5
2 0 8 8 0 0
6 8 5 2 7 7
7 5 4 3 7 6
2 7 1 0 1 5

output:

99 199 299 399 499 599 699 799 899 909 919 929 939 949 959 969 979 989 990 991 992 993 994 995 996 997 998 999 1099 1199 1299 1399 1499 1599 1699 1799 1899 1909 1919 1929 1939 1949 1959 1969 1979 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2099 2199 2299 2399 2499 2599 2699 2799 2899 2909...

result:

ok single line: '99 199 299 399 499 599 699 799...799 134899 134909 134919 134929'

Test #13:

score: 0
Accepted
time: 8ms
memory: 2748kb

input:

20 10000
5 9 4 8 3 3
1 1 9 2 8 9
6 3 3 0 2 1
2 6 0 3 6 4
3 6 4 2 9 4
8 6 7 3 7 3
3 6 2 0 5 9
5 3 3 5 8 9
1 4 4 5 8 0
1 3 1 4 7 8
6 9 9 8 3 3
1 7 2 8 9 3
0 2 2 8 5 9
9 0 1 2 2 5
5 0 9 1 6 9
0 8 7 7 3 2
7 7 2 7 3 3
3 6 6 6 0 0
7 5 3 5 5 9
9 2 0 0 8 0

output:

444444 1444444 2444444 3444444 4044444 4144444 4244444 4344444 4404444 4414444 4424444 4434444 4440444 4441444 4442444 4443444 4444044 4444144 4444244 4444344 4444404 4444414 4444424 4444434 4444440 4444441 4444442 4444443 4444444 4444445 4444446 4444447 4444448 4444449 4444454 4444464 4444474 44444...

result:

ok single line: '444444 1444444 2444444 3444444...4 404094444 404104444 404114444'

Test #14:

score: 0
Accepted
time: 5ms
memory: 2688kb

input:

20 10000
8 7 1 4 8 9
2 5 0 1 0 1
9 5 5 3 9 7
6 0 0 2 3 1
1 0 0 4 9 3
5 6 6 1 6 0
9 1 3 0 8 2
8 7 1 1 1 2
0 8 2 2 2 8
8 3 1 1 5 7
0 2 2 9 6 5
9 9 6 7 1 6
4 2 7 5 3 3
8 4 4 0 1 0
3 0 2 0 0 8
4 6 8 2 6 1
2 7 4 6 0 5
0 2 9 6 0 1
5 6 3 1 9 9
6 0 2 5 0 3

output:

4444444 14444444 24444444 34444444 40444444 41444444 42444444 43444444 44044444 44144444 44244444 44344444 44404444 44414444 44424444 44434444 44440444 44441444 44442444 44443444 44444044 44444144 44444244 44444344 44444404 44444414 44444424 44444434 44444440 44444441 44444442 44444443 44444444 4444...

result:

ok single line: '4444444 14444444 24444444 3444...443444484 3443444494 3443444544'

Test #15:

score: 0
Accepted
time: 79ms
memory: 9572kb

input:

50 100000
5 9 4 8 3 3
1 1 9 2 8 9
6 3 3 0 2 1
2 6 0 3 6 4
3 6 4 2 9 4
8 6 7 3 7 3
3 6 2 0 5 9
5 3 3 5 8 9
1 4 4 5 8 0
1 3 1 4 7 8
6 9 9 8 3 3
1 7 2 8 9 3
0 2 2 8 5 9
9 0 1 2 2 5
5 0 9 1 6 9
0 8 7 7 3 2
7 7 2 7 3 3
3 6 6 6 0 0
7 5 3 5 5 9
9 2 0 0 8 0
2 1 9 7 9 9
3 4 2 1 9 6
8 9 8 8 6 7
9 9 1 7 2 5
0 ...

output:

4444444444444444444 14444444444444444444 24444444444444444444 34444444444444444444 40444444444444444444 41444444444444444444 42444444444444444444 43444444444444444444 44044444444444444444 44144444444444444444 44244444444444444444 44344444444444444444 44404444444444444444 44414444444444444444 4442444...

result:

ok single line: '4444444444444444444 1444444444...44444444 4154449444444444444444'

Test #16:

score: 0
Accepted
time: 128ms
memory: 12752kb

input:

100 100000
5 9 4 8 3 3
1 1 9 2 8 9
6 3 3 0 2 1
2 6 0 3 6 4
3 6 4 2 9 4
8 6 7 3 7 3
3 6 2 0 5 9
5 3 3 5 8 9
1 4 4 5 8 0
1 3 1 4 7 8
6 9 9 8 3 3
1 7 2 8 9 3
0 2 2 8 5 9
9 0 1 2 2 5
5 0 9 1 6 9
0 8 7 7 3 2
7 7 2 7 3 3
3 6 6 6 0 0
7 5 3 5 5 9
9 2 0 0 8 0
2 1 9 7 9 9
3 4 2 1 9 6
8 9 8 8 6 7
9 9 1 7 2 5
0...

output:

7777777777777777777777777777777777 17777777777777777777777777777777777 27777777777777777777777777777777777 37777777777777777777777777777777777 47777777777777777777777777777777777 57777777777777777777777777777777777 67777777777777777777777777777777777 70777777777777777777777777777777777 7177777777777...

result:

ok single line: '777777777777777777777777777777...7777797777777777777777777777777'

Test #17:

score: 0
Accepted
time: 129ms
memory: 15140kb

input:

100 100000
8 7 1 4 8 9
2 5 0 1 0 1
9 5 5 3 9 7
6 0 0 2 3 1
1 0 0 4 9 3
5 6 6 1 6 0
9 1 3 0 8 2
8 7 1 1 1 2
0 8 2 2 2 8
8 3 1 1 5 7
0 2 2 9 6 5
9 9 6 7 1 6
4 2 7 5 3 3
8 4 4 0 1 0
3 0 2 0 0 8
4 6 8 2 6 1
2 7 4 6 0 5
0 2 9 6 0 1
5 6 3 1 9 9
6 0 2 5 0 3
4 9 2 2 4 7
5 4 0 1 3 3
1 7 1 8 0 0
8 7 3 3 5 2
3...

output:

44444444444444444444444444444444444444444444 77777777777777777777777777777777777777777777 144444444444444444444444444444444444444444444 177777777777777777777777777777777777777777777 244444444444444444444444444444444444444444444 277777777777777777777777777777777777777777777 34444444444444444444444444...

result:

ok single line: '444444444444444444444444444444...7777777777777777777777777777777'

Test #18:

score: 0
Accepted
time: 133ms
memory: 15024kb

input:

100 100000
6 8 7 7 0 0
0 5 1 9 4 1
5 9 6 9 5 4
0 4 6 9 1 6
2 8 7 4 4 0
0 1 4 3 9 2
3 0 2 1 3 4
6 5 4 1 6 3
7 1 3 6 9 4
4 5 1 3 6 2
4 3 0 2 4 7
8 8 3 5 8 6
9 7 7 0 3 1
9 5 9 9 8 3
2 0 9 1 2 5
8 0 0 0 0 3
1 2 5 9 3 2
2 3 5 6 1 2
0 0 4 0 6 2
4 6 9 4 0 8
2 9 7 1 7 4
0 3 1 8 0 9
7 5 9 6 2 7
7 0 0 4 8 4
6...

output:

222222222222222222222222222222222222222222 888888888888888888888888888888888888888888 1222222222222222222222222222222222222222222 1888888888888888888888888888888888888888888 2022222222222222222222222222222222222222222 2122222222222222222222222222222222222222222 22022222222222222222222222222222222222...

result:

ok single line: '222222222222222222222222222222...8888888888888880888888888888888'

Test #19:

score: 0
Accepted
time: 122ms
memory: 12884kb

input:

100 100000
0 4 1 3 9 6
9 6 2 1 8 6
5 3 0 7 7 3
0 2 8 0 8 4
2 4 1 2 9 7
9 3 2 7 4 4
6 2 5 4 2 1
8 4 7 8 0 9
8 7 9 0 6 3
6 5 6 3 7 2
5 9 5 2 3 4
7 9 1 7 8 0
1 2 6 2 5 6
0 7 5 6 4 2
9 5 2 1 1 0
3 9 9 0 3 2
1 0 3 1 3 7
6 7 7 4 9 6
9 6 1 2 8 2
6 7 8 8 7 0
3 6 9 3 9 6
0 6 7 1 2 7
2 4 6 0 4 3
9 9 8 0 6 4
5...

output:

777777777777777777777777777777777777 1777777777777777777777777777777777777 2777777777777777777777777777777777777 3777777777777777777777777777777777777 4777777777777777777777777777777777777 5777777777777777777777777777777777777 6777777777777777777777777777777777777 70777777777777777777777777777777777...

result:

ok single line: '777777777777777777777777777777...7777777777777777777777677777772'

Test #20:

score: 0
Accepted
time: 139ms
memory: 15196kb

input:

100 100000
1 4 7 5 6 0
2 3 8 4 9 0
1 2 8 8 3 0
7 9 9 7 2 9
4 7 1 9 3 6
4 4 5 4 0 5
7 4 5 9 6 3
4 7 0 2 9 2
6 0 2 2 6 9
9 1 7 2 6 4
1 7 9 0 5 3
9 4 6 7 2 6
7 1 7 0 9 3
9 9 4 3 5 3
9 7 9 4 2 4
0 7 7 4 5 0
3 0 1 1 2 1
6 9 2 1 2 8
6 9 0 1 6 4
8 1 9 6 5 4
2 0 4 6 0 9
0 7 5 9 4 0
1 0 0 5 1 8
8 9 8 1 4 9
5...

output:

6666666666666666666666666666666666666666 16666666666666666666666666666666666666666 26666666666666666666666666666666666666666 36666666666666666666666666666666666666666 46666666666666666666666666666666666666666 56666666666666666666666666666666666666666 60666666666666666666666666666666666666666 6166666...

result:

ok single line: '666666666666666666666666666666...6666636666666666666666666666966'

Test #21:

score: 0
Accepted
time: 42ms
memory: 8412kb

input:

10 100000
9 1 5 4 8 4
7 3 8 5 4 2
9 3 4 4 8 4
0 3 0 9 3 8
8 3 2 7 6 4
1 1 1 8 6 4
0 1 5 5 4 4
8 0 0 2 2 4
4 9 8 6 5 5
0 6 5 7 5 9

output:

1111 2222 7777 10111 11011 11101 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11121 11131 11141 11151 11161 11171 11181 11191 11211 11311 11411 11511 11611 11711 11811 11911 12111 12222 13111 14111 15111 16111 17111 17777 18111 19111 20222 21111 21222 22022 22122 22202 22212 22220 222...

result:

ok single line: '1111 2222 7777 10111 11011 111...7729224 7729225 7729226 7729227'

Test #22:

score: 0
Accepted
time: 34ms
memory: 8312kb

input:

10 100000
0 3 3 7 7 4
0 5 0 3 4 2
7 8 2 2 9 7
0 5 2 5 3 4
6 3 4 2 3 7
7 2 6 4 9 6
5 1 6 2 3 2
1 2 7 7 1 6
4 9 4 0 5 3
6 1 1 5 5 4

output:

88 188 288 388 488 588 688 788 808 818 828 838 848 858 868 878 880 881 882 883 884 885 886 887 888 889 898 988 1088 1111 1188 1288 1388 1488 1588 1688 1788 1808 1818 1828 1838 1848 1858 1868 1878 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1898 1988 2088 2188 2288 2388 2488 2588 2688 2788 2808...

result:

ok single line: '88 188 288 388 488 588 688 788...137 884138 884139 884140 884141'

Test #23:

score: 0
Accepted
time: 38ms
memory: 8700kb

input:

10 100000
8 6 2 1 9 5
3 6 5 2 9 8
5 2 5 7 3 6
4 1 7 1 5 9
8 4 6 3 8 0
3 1 7 0 6 4
8 6 8 1 9 9
4 6 5 2 3 7
3 6 3 3 0 8
1 6 7 5 3 6

output:

10000 20000 22222 30000 40000 44444 50000 60000 70000 80000 90000 99999 100000 100001 100002 100003 100004 100005 100006 100007 100008 100009 100010 100020 100030 100040 100050 100060 100070 100080 100090 100100 100200 100300 100400 100500 100600 100700 100800 100900 101000 102000 103000 104000 1050...

result:

ok single line: '10000 20000 22222 30000 40000 ...5000 23016000 23017000 23018000'

Test #24:

score: 0
Accepted
time: 9ms
memory: 3704kb

input:

5 10000
1 6 3 7 1 6
8 1 8 1 8 7
6 2 3 6 2 3
0 0 0 0 0 0
8 8 3 7 8 8

output:

4 5 9 14 15 19 22 24 25 29 34 35 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 64 65 69 74 75 79 84 85 89 90 91 92 93 94 95 96 97 98 99 100 104 105 109 111 114 115 119 122 124 125 129 134 135 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 164 165...

result:

ok single line: '4 5 9 14 15 19 22 24 25 29 34 ...6 11997 11998 11999 12000 12001'

Test #25:

score: 0
Accepted
time: 4ms
memory: 2716kb

input:

10 10000
1 9 7 6 1 9
2 1 8 9 2 1
7 9 7 9 7 9
0 5 0 5 0 5
7 3 2 9 7 3
2 9 2 2 9 2
0 5 3 5 9 2
8 8 8 8 8 8
3 0 5 5 3 0
5 7 3 5 7 3

output:

4 14 24 34 40 41 42 43 44 45 46 47 48 49 54 64 66 74 84 94 104 111 114 116 124 134 140 141 142 143 144 145 146 147 148 149 154 161 164 166 174 184 194 204 214 224 234 240 241 242 243 244 245 246 247 248 249 254 264 266 274 284 294 304 314 324 334 340 341 342 343 344 345 346 347 348 349 354 364 366 3...

result:

ok single line: '4 14 24 34 40 41 42 43 44 45 4...0 22841 22842 22843 22844 22845'

Test #26:

score: 0
Accepted
time: 38ms
memory: 8280kb

input:

20 100000
4 7 2 8 7 4
1 8 1 8 1 8
2 6 5 4 2 6
1 3 0 8 1 3
3 3 3 3 3 3
4 4 4 4 4 4
0 8 8 0 8 8
6 6 6 6 6 6
2 7 7 2 7 7
4 3 4 3 4 3
2 2 2 2 2 2
0 1 5 2 0 1
7 0 6 2 7 0
6 8 6 8 6 8
1 1 1 1 1 1
2 4 8 2 4 8
9 9 0 9 9 0
6 6 6 6 6 6
5 0 0 9 4 5
4 3 1 7 4 3

output:

999 1999 2999 3999 4999 5555 5999 6999 7999 8999 9099 9199 9299 9399 9499 9599 9699 9799 9899 9909 9919 9929 9939 9949 9959 9969 9979 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10999 11999 12999 13999 14999 15555 15999 16999 17999 18999 19099 19199 19299 19399 19499 19599 19699 19799 198...

result:

ok single line: '999 1999 2999 3999 4999 5555 5...5505591 5505592 5505593 5505594'

Test #27:

score: 0
Accepted
time: 47ms
memory: 8720kb

input:

60 100000
0 7 3 7 0 7
7 7 7 7 7 7
0 5 4 4 5 0
8 1 8 8 1 8
9 2 3 9 2 3
0 1 0 1 0 1
0 5 0 5 0 5
3 4 3 4 3 4
9 9 9 9 9 9
7 9 7 9 7 9
1 2 5 1 2 5
1 2 1 1 2 1
4 0 2 5 4 0
9 9 9 9 9 9
6 1 6 1 6 1
0 9 0 9 0 9
9 2 6 8 9 2
5 7 7 5 7 7
9 9 9 9 9 9
2 5 2 5 2 5
9 9 9 9 9 9
4 0 8 4 0 8
7 7 7 7 7 7
8 9 8 9 8 9
1 ...

output:

666666666 1666666666 2666666666 3666666666 4666666666 5666666666 6066666666 6166666666 6266666666 6366666666 6466666666 6566666666 6606666666 6616666666 6626666666 6636666666 6646666666 6656666666 6660666666 6661666666 6662666666 6663666666 6664666666 6665666666 6666066666 6666166666 6666266666 6666...

result:

ok single line: '666666666 1666666666 266666666...06166 666666006266 666666006366'

Test #28:

score: 0
Accepted
time: 66ms
memory: 9388kb

input:

80 100000
2 7 2 7 2 7
9 3 9 3 9 3
4 4 4 4 4 4
5 9 1 2 7 5
2 2 2 2 2 2
4 7 4 7 4 7
1 8 1 8 1 8
5 2 5 2 5 2
0 8 0 8 0 8
2 2 4 3 1 2
0 6 0 6 0 6
3 3 3 3 3 3
9 2 9 5 9 2
0 6 0 6 0 6
5 5 5 5 5 5
1 1 1 1 1 1
9 8 1 7 1 5
0 8 4 8 7 0
8 0 4 8 0 4
1 5 4 1 8 1
9 0 9 0 9 0
7 1 7 1 7 1
4 3 8 7 4 3
6 5 6 5 6 5
3 ...

output:

222222222222222 555555555555555 1222222222222222 1555555555555555 2022222222222222 2122222222222222 2202222222222222 2212222222222222 2220222222222222 2221222222222222 2222022222222222 2222122222222222 2222202222222222 2222212222222222 2222220222222222 2222221222222222 2222222022222222 2222222122222...

result:

ok single line: '222222222222222 55555555555555...222262222229 222202222262222232'

Test #29:

score: 0
Accepted
time: 72ms
memory: 9732kb

input:

100 100000
4 6 8 6 6 4
8 8 8 8 8 8
0 0 0 0 0 0
6 6 6 6 6 6
5 2 3 3 8 5
9 9 9 9 9 9
1 4 5 9 1 4
4 4 1 4 4 4
2 8 5 2 8 5
3 4 3 6 3 4
1 4 1 3 3 1
5 6 5 6 5 6
6 7 1 6 7 1
8 8 8 8 8 8
3 3 3 3 3 3
6 6 6 6 6 6
9 9 9 9 9 9
0 5 9 0 5 9
1 3 7 1 3 7
5 6 5 6 5 6
1 1 1 1 1 1
7 7 7 7 7 7
5 3 5 3 5 3
6 0 5 7 6 0
9...

output:

111111111111111111 1011111111111111111 1101111111111111111 1110111111111111111 1111011111111111111 1111101111111111111 1111110111111111111 1111111011111111111 1111111101111111111 1111111110111111111 1111111111011111111 1111111111101111111 1111111111110111111 1111111111111011111 1111111111111101111 1...

result:

ok single line: '111111111111111111 10111111111...111111519 111111111110111111521'

Test #30:

score: 0
Accepted
time: 82ms
memory: 9720kb

input:

100 100000
4 4 4 4 4 4
7 2 4 7 2 4
2 3 6 2 3 6
1 3 1 3 1 3
2 2 2 2 2 2
9 0 2 8 4 9
1 2 1 1 2 1
5 9 1 5 9 1
3 5 0 1 7 3
5 7 1 5 7 1
8 5 0 8 8 5
7 4 7 4 7 4
5 5 5 5 5 5
9 7 7 7 1 9
9 0 3 5 9 0
1 5 5 2 1 5
0 2 0 0 2 0
4 2 8 4 4 2
5 5 5 5 5 5
3 3 3 3 3 3
0 8 9 2 5 5
9 6 9 6 9 6
8 2 2 5 6 9
7 7 7 7 7 7
3...

output:

8888888888888888888 10000000000000000000 18888888888888888888 20000000000000000000 28888888888888888888 30000000000000000000 38888888888888888888 40000000000000000000 48888888888888888888 50000000000000000000 58888888888888888888 60000000000000000000 68888888888888888888 70000000000000000000 7888888...

result:

ok single line: '8888888888888888888 1000000000...00000000 3000700000000300000000'

Test #31:

score: 0
Accepted
time: 86ms
memory: 9560kb

input:

100 100000
0 0 0 0 0 0
4 4 1 9 4 4
0 7 0 7 0 7
5 1 9 4 4 0
1 3 1 7 2 1
9 3 4 1 4 9
9 9 9 9 9 9
3 2 4 9 0 3
9 9 9 9 9 9
0 4 2 3 2 0
2 2 2 2 2 2
7 8 7 8 7 8
5 7 5 5 7 5
8 8 8 8 8 8
7 6 4 5 7 6
0 0 0 0 0 0
0 3 4 0 3 4
1 8 3 1 8 3
5 7 1 0 5 7
2 2 2 2 2 2
3 4 2 3 4 2
0 0 0 0 0 0
7 7 7 7 7 7
2 6 7 2 8 2
2...

output:

666666666666666666 1666666666666666666 2666666666666666666 3666666666666666666 4666666666666666666 5666666666666666666 6066666666666666666 6166666666666666666 6266666666666666666 6366666666666666666 6466666666666666666 6566666666666666666 6606666666666666666 6616666666666666666 6626666666666666666 6...

result:

ok single line: '666666666666666666 16666666666...666666666 606666663669666666666'

Extra Test:

score: 0
Extra Test Passed