結果
問題 |
No.930 数列圧縮
|
ユーザー |
|
提出日時 | 2019-11-22 21:55:35 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,485 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 122,352 KB |
実行使用メモリ | 17,192 KB |
最終ジャッジ日時 | 2024-06-22 03:03:30 |
合計ジャッジ時間 | 3,877 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 17 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; int[] solve() { int[][] B; int tmp = 1 << 29; foreach (a; A) { if (a > tmp) { B.back ~= a; tmp = a; } else { B ~= [a]; tmp = a; } } if (B.length > 1 && B[0..$-1].map!(b => b.front > B.back.back).any) { return []; } int[] ans; foreach (i; 0..B.length.to!int-1) { foreach (j; 1..B[i].length) { ans ~= B[i][j]; } } foreach_reverse (i; 0..B.back.length.to!int-1) { ans ~= B.back[i]; } foreach_reverse (i; 0..B.length.to!int-1) { ans ~= B[i].front; } return ans; } auto ans = solve; if (ans.length > 0) { writeln("Yes"); ans.map!(to!string).join(" ").writeln; return; } foreach (i; 0..N/2) { swap(A[i], A[N-i-1]); } foreach (i; 0..N) { A[i] *= -1; } ans = solve; if (ans.length > 0) { writeln("Yes"); ans.map!(a => -a).map!(to!string).join(" ").writeln; } else { writeln("No"); } }