Submission #1357632


Source Code Expand

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        long N = Reader.Long() + 1;
        var ans = new List<int>();
        int i = Enu.Range(0, 60).Last(x => (N >> x & 1) == 1) - 1;
        ans.Add(1);

        for (int num = 2; i >= 0; i--)
        {
            if ((N >> i & 1) == 1) ans.Insert(0, num++);
            if (i != 0) ans.Add(num++);
        }
        ans.AddRange(Enu.Range(1, ans.Count));

        Console.WriteLine(ans.Count + "\n" + string.Join(" ", ans));
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Submission Info

Submission Time
Task C - Tautonym Puzzle
User eitaho
Language C# (Mono 4.6.2.0)
Score 1000
Code Size 2565 Byte
Status AC
Exec Time 24 ms
Memory 13268 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 32
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 23 ms 9172 KB
00_example_02.txt AC 24 ms 13268 KB
01.txt AC 24 ms 13268 KB
02.txt AC 23 ms 9172 KB
03.txt AC 23 ms 11348 KB
04.txt AC 24 ms 11220 KB
05.txt AC 24 ms 11220 KB
06.txt AC 24 ms 13268 KB
07.txt AC 24 ms 13268 KB
08.txt AC 23 ms 11220 KB
09.txt AC 24 ms 13268 KB
10.txt AC 23 ms 11220 KB
11.txt AC 24 ms 11220 KB
12.txt AC 24 ms 11220 KB
13.txt AC 23 ms 11220 KB
14.txt AC 24 ms 11220 KB
15.txt AC 23 ms 11220 KB
16.txt AC 24 ms 13268 KB
17.txt AC 24 ms 11220 KB
18.txt AC 24 ms 13268 KB
19.txt AC 23 ms 11220 KB
20.txt AC 23 ms 11220 KB
21.txt AC 23 ms 11348 KB
22.txt AC 23 ms 9300 KB
23.txt AC 24 ms 11220 KB
24.txt AC 24 ms 11220 KB
25.txt AC 24 ms 11348 KB
26.txt AC 23 ms 11220 KB
27.txt AC 24 ms 11220 KB
28.txt AC 24 ms 13140 KB
29.txt AC 23 ms 11220 KB
30.txt AC 23 ms 9300 KB