結果
問題 | No.2209 Flip and Reverse |
ユーザー |
![]() |
提出日時 | 2023-02-11 17:31:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 1,518 ms |
コンパイル使用メモリ | 106,880 KB |
実行使用メモリ | 27,648 KB |
最終ジャッジ日時 | 2024-07-08 05:35:09 |
合計ジャッジ時間 | 4,627 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math;using System.Collections.Generic;using System.Linq;using System;public class Hello{static void Main(){var n = int.Parse(Console.ReadLine().Trim());var s = Console.ReadLine().Trim();var t = Console.ReadLine().Trim();getAns(n, s, t);}static void getAns(int n, string s, string t){var cs1 = s.Count(x => x == '1');var ct1 = t.Count(x => x == '1');var d = Abs(cs1 - ct1);var c = 0;if (d % 2 == 0){for (int i = 0; i < n; i++){if (s[i] != t[i]) c++;}}else{var t2 = t.ToCharArray();Array.Reverse(t2);for (int i = 0; i < n; i++){if (s[i] != t2[i]) c++;}}Console.WriteLine(c);}}