Code Submission Evaluation System Login

Datatähti 2016 alku

Start:2015-09-28 00:00:00
End:2015-10-12 00:00:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2016 alku - Results
History
2015-10-11 18:35:450
2015-10-11 18:34:21
2015-10-11 18:30:45
2015-10-11 18:29:15
2015-10-10 21:49:2647
2015-10-07 10:17:460
2015-10-06 18:48:3114
2015-10-06 18:41:490
2015-10-06 00:50:570
2015-10-06 00:40:010
Task:Tontti
Sender:BigKappa
Submission time:2015-10-10 21:49:26
Language:Java
Status:READY
Score:47

Feedback

groupverdictscore
#1ACCEPTED14
#2ACCEPTED33
#3TIME LIMIT EXCEEDED0

Test results

testverdicttime (s)group
#1ACCEPTED0.17 / 1.001details
#2ACCEPTED0.17 / 1.001details
#3ACCEPTED0.16 / 1.001details
#4ACCEPTED0.18 / 1.001details
#5ACCEPTED0.17 / 1.001details
#6ACCEPTED0.39 / 1.002details
#7ACCEPTED0.30 / 1.002details
#8ACCEPTED0.29 / 1.002details
#9ACCEPTED0.28 / 1.002details
#10ACCEPTED0.30 / 1.002details
#11TIME LIMIT EXCEEDED-- / 1.003details
#12TIME LIMIT EXCEEDED-- / 1.003details
#13ACCEPTED0.54 / 1.003details
#14ACCEPTED0.63 / 1.003details
#15ACCEPTED0.68 / 1.003details

Code

public class Tontti{
 
    static int height;
    static int width;
    static int[][] kenttaSumma;
    static int wantedTrees;
    //static long runAmount;
 
    public static void main(String[] args){
 
        /*//todo
        int futureWidth = 500;
        int futureHeight = 500;
        int futurewantedTrees = (int) (Math.random() * futureHeight);
        height = futureHeight;
        width = futureWidth;
        wantedTrees = futurewantedTrees;
 
        kentta = new byte[width+1][height+1];
        kenttaSumma = new int[width+1][height+1];
 
        String[] lines = new String[height+1];
        for (int y=1; y<=height; y++) {
            //todo
            lines[y] = "";
            for (int x2=1; x2<=width; x2++){
                if (Math.random() > 0.3){
                    lines[y] = lines[y] + ".";
                }else {
                    lines[y] = lines[y] + "*";
                }
            }
        }*/
 
 
        IO io = new IO();
 
        height = io.nextInt();
        width = io.nextInt();
        wantedTrees = io.nextInt();
 
        //long aika = System.nanoTime();
 
 
        kenttaSumma = new int[width+1][height+1];
 
        int foundArea = 0;
        int minSize = (int) (Math.sqrt(wantedTrees) + 0.99);
 
        //calculate trees and save it in to array and summed area table
        for (int y=1; y<=height; y++) {
            String line = io.next();
            //String line = lines[y];
 
            int sumRow = 0;
            for (int x=1; x<=width; x++){
                if (line.charAt(x-1) == '*'){
                    sumRow ++;
                }
                kenttaSumma[x][y] = sumRow + kenttaSumma[x][y-1];
 
                int maxSize = min(x, y);
 
                /*//todo remove
                if (x==2 && y==2){
                    //stop here
                    int a=0;
                }*/
 
                if(maxSize >= minSize){
                    foundArea += countAreasB(maxSize,minSize,x,y,0);
                }
 
            }
        }
 
        io.println(foundArea);
 
        /*aika = (System.nanoTime()-aika)/1000000;
        io.println("---");
        io.println("Time: " + aika);
        io.println("Loops: " + runAmount);
        */
 
        io.close();
    }
 
    //rekursiivinen binaarihaku
    // x2 = x -1
    // y2 = y -1
    private static int countAreasB(int maxSize,int minSize, int x, int y, int prevSize){
        int areasFound = 0;
        int tSize = (int) ((maxSize + minSize)/2.0 + 0.99);
 
        //lopetaan kun sama on jo katsottu
        if (prevSize != tSize){
            prevSize = tSize;
 
            int sum = kenttaSumma[x][y]+kenttaSumma[x-tSize][y-tSize]-kenttaSumma[x][y-tSize]-kenttaSumma[x-tSize][y];
 
            if(sum > wantedTrees){
                tSize = (tSize - minSize == 1)?minSize:tSize;
                areasFound += countAreasB(tSize, minSize, x, y, prevSize);
            }else if (sum < wantedTrees){
                areasFound += countAreasB(maxSize, tSize, x, y, prevSize);
            }else {
                //molemmat suunnat ovat mahdollisia --> kokeillaan kaikki lahella olevat
                areasFound ++;
                areasFound += countAreasL(tSize+1, maxSize, x, y, 1);
                areasFound += countAreasL(tSize-1, minSize, x, y, -1);
            }
        }
       
        return areasFound;
    }
 
    //suoraviivainen haku
    // x2 = x-1
    // y2 = y-1
    private static int countAreasL(int startSize,int endSize, int x, int y, int direction){
        int areasFound = 0;
 
        for (int tSize=startSize; direction*tSize<=endSize*direction; tSize=tSize+direction){
 
            int sum = kenttaSumma[x][y]+kenttaSumma[x-tSize][y-tSize]-kenttaSumma[x][y-tSize]-kenttaSumma[x-tSize][y];
            if (sum == wantedTrees){
                areasFound ++;
            }else{
                break;
            }
 
        }
 
        return areasFound;
    }
 
    //just for lulz
    private static int max(final int a, final int b){
        return (a>b)?a:b;
    }
    private static int min(final int a, final int b){
        return (a<b)?a:b;
    }}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
10 10 1
......*...
.......*..
*..*....*.
*....*....
..........
..........
..*.......
....*.....
..........
.........*
view   save

correct output
94
view   save

user output
94
view   save

Test 2

Group: 1

Verdict: ACCEPTED

input
10 10 5
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
view   save

correct output
0
view   save

user output
0
view   save

Test 3

Group: 1

Verdict: ACCEPTED

input
10 10 10
**...*...*
*..*.**.*.
...**.*..*
*...**.*..
***.*.*.*.
.*.*.*.**.
*..*.*....
.*.***...*
**.*......
..*...**.*
view   save

correct output
4
view   save

user output
4
view   save

Test 4

Group: 1

Verdict: ACCEPTED

input
10 10 5
****......
*.*.**..**
....*.*..*
...*.***..
.*..*.**..
.***.*....
*...*.*...
*.*....*.*
.*.***..*.
.*..*..**.
view   save

correct output
16
view   save

user output
16
view   save

Test 5

Group: 1

Verdict: ACCEPTED

input
10 10 2
**.***..*.
...*.*....
.***.*...*
***.***..*
..*.******
...*.....*
*.***.*.**
..***.**.*
*.*.******
*..*.*..**
view   save

correct output
30
view   save

user output
30
view   save

Test 6

Group: 2

Verdict: ACCEPTED

input
500 500 1
.................................
.................................
view   save

correct output
9552040
view   save

user output
9552040
view   save

Test 7

Group: 2

Verdict: ACCEPTED

input
500 500 5
.................................
.................................
view   save

correct output
1536063
view   save

user output
1536063
view   save

Test 8

Group: 2

Verdict: ACCEPTED

input
500 500 25000
**...*...**..*.*..*.**.*..*.*....
.**.*.**.**....*.*.***...........
view   save

correct output
288
view   save

user output
288
view   save

Test 9

Group: 2

Verdict: ACCEPTED

input
500 500 12500
**.**.*..*...*.**...*.***........
************.*....**..*.*.*.**...
view   save

correct output
786
view   save

user output
786
view   save

Test 10

Group: 2

Verdict: ACCEPTED

input
500 500 5000
.*.*.**..*.*.**.**..*..**...*....
**..*...*..**..***.*..*****......
view   save

correct output
1763
view   save

user output
1763
view   save

Test 11

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 1
.................................
view   save

correct output
489611392
view   save

user output
(no output)
view   save

Test 12

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 5
.................................
view   save

correct output
120725884
view   save

user output
(no output)
view   save

Test 13

Group: 3

Verdict: ACCEPTED

input
2000 2000 400000
..*..**.**.**.*.***...**.*..**...
view   save

correct output
1849
view   save

user output
1849
view   save

Test 14

Group: 3

Verdict: ACCEPTED

input
2000 2000 200000
***.*....*.*..*....**..*..*.*....
view   save

correct output
2665
view   save

user output
2665
view   save

Test 15

Group: 3

Verdict: ACCEPTED

input
2000 2000 80000
**.**...*.***.**....**.*....*....
view   save

correct output
5587
view   save

user output
5587
view   save