AtCoder Beginner Contest 019

Submission #347146

Source codeソースコード

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    void calc()
    {
        Scanner cin = new Scanner();
        string s = cin.next();

        int count = 0;
        char pre = ' ';
        string ret = "";
        foreach (var c in s)
        {
            if (c == pre)
            {
                count++;
            }
            else
            {
                if (count != 0)
                {
                    ret += pre;
                    ret += count;
                }
                pre = c;
                count = 1;
            }
        }
        if (count != 0)
        {
            ret += pre;
            ret += count;
        }

        Console.WriteLine(ret);
    }

}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}


class XRand
{
    uint x, y, z, w;


    public XRand()
    {
        init();
    }

    public XRand(uint s)
    {
        init();
        init_xor128(s);
    }

    void init()
    {
        x = 314159265; y = 358979323; z = 846264338; w = 327950288;

    }

    public void init_xor128(uint s)
    {
        z ^= s;
        z ^= z >> 21; z ^= z << 35; z ^= z >> 4;
        z *= 736338717;
    }

    uint next()
    {
        uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
    }

    public long nextLong(long m)
    {
        return (long)((((ulong)next() << 32) + next()) % (ulong)m);
    }

    public int nextInt(int m)
    {
        return (int)(next() % m);
    }

    public long nextLong(long min, long max)
    {
        return min + nextLong(max - min + 1);
    }

    public int nextInt(int min, int max)
    {
        return min + nextInt(max - min + 1);
    }

    public int nextIntP(int a)
    {
        return (int)Math.Pow(a, nextDouble());
    }

    public int nextIntP(int min, int max)
    {
        int diff = max - min;
        return min + nextIntP(diff + 2) - 1;
    }

    public long nextLongP(long a)
    {
        return (long)Math.Pow(a, nextDouble());
    }

    public long nextLongP(long min, long max)
    {
        long diff = max - min;
        return min + nextLongP(diff + 2) - 1;
    }


    public double nextDouble()
    {
        return (double)next() / uint.MaxValue;
    }

    public double nextDoubleP(double a)
    {
        return Math.Pow(a, nextDouble());
    }
}

Submission

Task問題 B - 高橋くんと文字列圧縮
User nameユーザ名 chokudai
Created time投稿日時
Language言語 C# (Mono 2.10.8.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 3286 Byte
File nameファイル名
Exec time実行時間 167 ms
Memory usageメモリ使用量 7360 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_1.txt,subtask0_2.txt,subtask0_3.txt
All 100 / 100 0.txt,1.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,2.txt,20.txt,21.txt,22.txt,23.txt,24.txt,25.txt,26.txt,27.txt,28.txt,29.txt,3.txt,4.txt,5.txt,6.txt,7.txt,8.txt,9.txt,subtask0_1.txt,subtask0_2.txt,subtask0_3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0.txt AC 157 ms 7228 KB
1.txt AC 156 ms 7272 KB
10.txt AC 146 ms 7076 KB
11.txt AC 143 ms 7076 KB
12.txt AC 144 ms 7092 KB
13.txt AC 142 ms 7096 KB
14.txt AC 151 ms 7100 KB
15.txt AC 142 ms 7100 KB
16.txt AC 142 ms 7140 KB
17.txt AC 142 ms 7096 KB
18.txt AC 142 ms 7100 KB
19.txt AC 143 ms 7140 KB
2.txt AC 151 ms 7276 KB
20.txt AC 140 ms 7036 KB
21.txt AC 148 ms 7032 KB
22.txt AC 158 ms 7092 KB
23.txt AC 164 ms 7084 KB
24.txt AC 167 ms 6992 KB
25.txt AC 144 ms 7088 KB
26.txt AC 144 ms 7028 KB
27.txt AC 144 ms 7088 KB
28.txt AC 140 ms 7064 KB
29.txt AC 143 ms 7020 KB
3.txt AC 149 ms 7288 KB
4.txt AC 149 ms 7288 KB
5.txt AC 152 ms 7296 KB
6.txt AC 152 ms 7312 KB
7.txt AC 149 ms 7360 KB
8.txt AC 145 ms 7224 KB
9.txt AC 154 ms 7296 KB
subtask0_1.txt AC 141 ms 7080 KB
subtask0_2.txt AC 145 ms 7012 KB
subtask0_3.txt AC 152 ms 7068 KB