結果
問題 | No.197 手品 |
ユーザー |
|
提出日時 | 2016-09-01 11:22:19 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 1,096 ms |
コンパイル使用メモリ | 113,280 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 04:05:29 |
合計ジャッジ時間 | 2,434 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random; import std.string, std.conv, std.stdio, std.typecons; void main() { auto s1 = readln.chomp; auto n = readln.chomp.to!long; auto s2 = readln.chomp; writeln(calc(s1, s2, n) ? "SUCCESS" : "FAILURE"); } bool calc(string s1, string s2, long n) { if (s1.count('o') != s2.count('o')) return true; if (s1.count('o') == 0 || s1.count('o') == 3) return false; if (n == 0) { return s1 != s2; } else if (n >= 2) { return false; } int p1, p2; if (s1.count('o') == 1) { p1 = s1.countUntil('o').to!int; p2 = s2.countUntil('o').to!int; } else { p1 = s1.countUntil('x').to!int; p2 = s2.countUntil('x').to!int; } if (p1 == 1) { return p2 == 1; } else { return p1 != p2 && p2 != 1; } }