0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

paizaオンラインハッカソン5「俺(エンジニア)の許嫁と幼なじみが修羅場すぎる」をやってみた

Last updated at Posted at 2015-05-02

POH5で書いたC#のコードを公開。
所要時間は、1問目と2問目は数分。レナが40分ほど、ミナミは25分ぐらい。

###1問目
修正したけど変数名のoddとevenを間違えていたのはここだけの秘密。てへ

public class Hello{
    public static void Main(){
        var line = System.Console.ReadLine();

        var even = true;
        foreach(var c in line) {
        	if(even) System.Console.Write(c);
        	even = !even;
        }
        System.Console.Write(System.Environment.NewLine);
    }
}

##2問目

public class Hello{
    public static void Main(){
        var n = System.Convert.ToInt32(System.Console.ReadLine());
        int[] totals = {0,0,0,0,0,0,0};
        for(var i=0; i<n; i++) {        	
        	totals[i%7] += System.Convert.ToInt32(System.Console.ReadLine()); 
        }
        foreach(var total  in totals) {
	        System.Console.WriteLine(total);
        }
    }
}

##レナ

using System;
public class Hello{
    public static void Main(){
        var line = Console.ReadLine();
        var lineFields = line.Split(' ');
        var x = Convert.ToInt32(lineFields[0]); 
        var y = Convert.ToInt32(lineFields[1]); 
        var N = Convert.ToInt32(lineFields[2]); 

        int[,] array = new int[x, y];

        for(var yy=0; yy < y; yy++) {
            var data = Console.ReadLine();
            var dataFields = data.Split(' ');
            for(var xx=0; xx < x; xx++) {
                array[xx, yy] = Convert.ToInt32(dataFields[xx]);
            }
        }

        bool[,] table = new bool[x, y];
        for(var i=0; i < N; i++) {
            var select = Console.ReadLine();
            var selectFields = select.Split(' ');
            var xs = Convert.ToInt32(selectFields[0]); 
            var ys = Convert.ToInt32(selectFields[1]); 
            var xe = Convert.ToInt32(selectFields[2]); 
            var ye = Convert.ToInt32(selectFields[3]); 
            
            for(var tx=xs; tx<=xe; tx++) {
                for(var ty=ys; ty<=ye; ty++) {
                    table[tx-1, ty-1] = true;
                }
            } 
        }            

        var sum = 0; 
        for(var yy=0; yy < y; yy++) {        	
            for(var xx =0; xx < x; xx++) {
                sum += table[xx, yy] ? array[xx,yy] : 0;
            }
        }
	    
        System.Console.WriteLine(sum);
    }
}

##ミナミ

using System;
public class Hello{
    public static void Main(){
        var line = Console.ReadLine();
        var lineFields = line.Split(' ');
        var x = Convert.ToInt32(lineFields[0]); 
        var y = Convert.ToInt32(lineFields[1]); 

        int[] array = new int[x];

        for(var i=0; i < y; i++) {
            var data = Console.ReadLine();
            var fields = data.Split(' ');
            
            for(var j=0; j < x; j++) {
               if(fields[j] == "1") array[j]++; 
            }
        }

        for(var i=0; i < y; i++) {
            var outLine = String.Empty;  
            for(var j=0; j < x; j++) {
                if(y-i <= array[j]) {
                    outLine += "1 ";
                } else {
                    outLine += "0 ";
                }
            }
            Console.WriteLine(outLine.TrimEnd());
        }

    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?