結果
問題 |
No.342 一番ワロタww
|
ユーザー |
![]() |
提出日時 | 2017-10-11 23:26:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 3,711 bytes |
コンパイル時間 | 1,016 ms |
コンパイル使用メモリ | 114,524 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-10-15 13:36:14 |
合計ジャッジ時間 | 2,189 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProgrammingContest { class MainClass { Scanner sc; static void Main(string[] args) { new MainClass().Solve(); } void Solve() { #if DEBUG string backPath = ".."; char dirSep = System.IO.Path.DirectorySeparatorChar; string inFilePath = backPath + dirSep + backPath + dirSep + "in.txt"; sc = new Scanner(new System.IO.StreamReader(inFilePath)); #else sc = new Scanner(); #endif string s = sc.Next; List<Tuple<string, int>> list = new List<Tuple<string, int>>(); { string buf = string.Empty; int wCnt = 0; foreach (var c in s) { if (c == 'w') { if (!string.IsNullOrEmpty(buf)) { wCnt++; } } else { if (wCnt > 0) { list.Add(Tuple.Create(buf, wCnt)); buf = string.Empty; wCnt = 0; } buf += c; } } if (!string.IsNullOrEmpty(buf) && wCnt > 0) { list.Add(Tuple.Create(buf, wCnt)); } } int ma = 0; foreach (var el in list) { if (ma < el.Item2) { ma = el.Item2; } } foreach (var el in list) { if (ma == el.Item2) { Write(el.Item1); } } } void Write(object val) { Console.WriteLine(val.ToString()); } void Write(string format, params object[] vals) { Console.WriteLine(format, vals); } } class Scanner { Queue<String> buffer; char[] sep; System.IO.TextReader reader; public Scanner(System.IO.TextReader reader = null) { this.buffer = new Queue<string>(); this.sep = new char[] { ' ' }; this.reader = (reader ?? Console.In); } private void CheckBuffer() { if (this.buffer.Count == 0 && this.reader.Peek() >= 0) { string[] sreArray = this.reader.ReadLine().Split(this.sep); foreach (String elStr in sreArray) { this.buffer.Enqueue(elStr); } } } public String Next { get { this.CheckBuffer(); return this.buffer.Dequeue(); } } public int NextInt { get { return int.Parse(this.Next); } } public double NextDouble { get { return double.Parse(this.Next); } } public long NextLong { get { return long.Parse(this.Next); } } public bool IsEmpty { get { this.CheckBuffer(); return this.buffer.Count == 0; } } } }