93962024-02-21 12:36:02Leventusz09Táblajáték 2 (70 pont)csharpWrong answer 26/7032ms26808 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Táblajáték_2{
    class Program{
        static void Main(){
            int K = int.Parse(Console.ReadLine());
            int[] S = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //K = 80;
            //S = "1 0 2 1 0 2 1 0 2 4 3 2 3 2 5 5 0 2 0 3 0 2 4 5 4 0 5 5 5 2 4 4 2 3 4 4 0 4 3 3 0 3 5 4 3 0 2 2 1 1 4 4 2 1 3 0 0 1 3 0 3 1 3 2 5 5 4 2 2 3 2 5 4 0 0 5 4 3 4 1".Split().Select(int.Parse).ToArray();


            /*string o1 = "00";

            for(int i=0, l; i<K; i++){
                l = o1.Length;
                if (S[i] == 0) o1 += "0";
                else if (S[i] == 1) o1 += "1";
                else if (S[i] == 2) o1 += "2";
                else if (S[i] == 3) o1 = o1.Substring(0, l - 1);
                else if (S[i] == 4) 
                    
                    if (o1[l - 1] == '0') 
                        o1 = o1.Substring(0, l - 2) + (int.Parse(o1[l - 2] + "") - 1) + "2"; 
                    else 
                        o1 = o1.Substring(0, l - 1) + (int.Parse(o1[l - 1] + "") - 1);
                else 
                    if (o1[l - 1] == '2')
                        o1 = o1.Substring(0, l - 2) + (int.Parse(o1[l - 2] + "") + 1) + "0"; 
                    else 
                        o1 = o1.Substring(0, l - 1) + (int.Parse(o1[l - 1] + "") + 1);
            }
            int o2 = int.Parse(o1);*/

            int r = 0, c = 0;

            foreach(int i in S){
                if (i == 0){
                    r++;
                    c *= 3;
                }else if (i == 1){
                    r++;
                    c = c * 3 + 1;
                }else if (i == 2){
                    r++;
                    c = c * 3 + 2;
                }else if (i == 3){
                    r--;
                    c /= 3;
                }else if (i == 4){
                    c--;
                }else c++;
            }

            int o1 = 0;
            for (int i=(int)((Math.Log(c) / Math.Log(3))), t; i>=0 ; i--){
                t = (int)(c / Math.Pow(3, i));
                c -= t * (int)Math.Pow(3, i);
                o1 = o1 * 10 + t;
            }
            Console.WriteLine("{0}\n{1}", r, o1);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base26/70
1Accepted0/032ms22344 KiB
2Wrong answer0/030ms22548 KiB
3Accepted2/230ms22760 KiB
4Partially correct1/332ms23364 KiB
5Accepted3/332ms23668 KiB
6Partially correct1/332ms24240 KiB
7Partially correct1/332ms24168 KiB
8Partially correct1/332ms24768 KiB
9Partially correct1/330ms24940 KiB
10Partially correct1/330ms25068 KiB
11Partially correct1/330ms25204 KiB
12Partially correct1/332ms25308 KiB
13Partially correct1/332ms25772 KiB
14Partially correct1/332ms25488 KiB
15Partially correct1/430ms25484 KiB
16Partially correct1/432ms25908 KiB
17Partially correct1/430ms25960 KiB
18Partially correct1/430ms25964 KiB
19Partially correct1/430ms26272 KiB
20Partially correct1/430ms26616 KiB
21Partially correct1/430ms26808 KiB
22Partially correct1/430ms26312 KiB
23Accepted3/329ms26188 KiB