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 22:04:2947
2015-10-11 22:00:4714
2015-10-11 21:59:1647
2015-10-11 21:58:2147
2015-10-11 21:55:1347
2015-10-11 21:43:1747
2015-10-10 20:58:3147
2015-10-08 15:00:0633
2015-10-03 14:59:1847
2015-10-03 14:58:490
2015-10-02 12:47:590
2015-10-02 12:10:5947
2015-10-02 12:10:240
2015-10-02 12:09:550
2015-10-02 12:09:2614
2015-10-02 12:08:2014
2015-10-02 12:07:070
2015-10-02 12:06:230
2015-10-01 21:44:4647
2015-10-01 21:07:2147
2015-10-01 20:37:2647
2015-10-01 20:25:2447
2015-10-01 20:04:2847
2015-10-01 20:02:1347
2015-10-01 19:58:580
2015-10-01 18:32:4647
2015-10-01 17:39:1047
2015-10-01 17:02:100
2015-10-01 17:00:210
2015-10-01 15:08:0847
2015-10-01 15:04:450
2015-10-01 15:03:370
2015-10-01 14:51:0947
2015-10-01 14:34:5947
2015-10-01 14:19:480
2015-09-30 18:23:450
2015-09-30 12:06:2414
2015-09-29 19:04:040
2015-09-29 18:40:120
2015-09-29 11:49:1414
2015-09-28 18:11:380
2015-09-28 17:47:360
2015-09-28 17:44:220
2015-09-28 17:29:480
2015-09-28 17:23:160
2015-09-28 17:20:390
2015-09-28 17:01:570
2015-09-28 17:01:21
Task:Tontti
Sender:kalh
Submission time:2015-10-11 22:04:29
Language:Java
Status:READY
Score:47

Feedback

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

Test results

testverdicttime (s)group
#1ACCEPTED0.17 / 1.001details
#2ACCEPTED0.18 / 1.001details
#3ACCEPTED0.18 / 1.001details
#4ACCEPTED0.17 / 1.001details
#5ACCEPTED0.18 / 1.001details
#6ACCEPTED0.43 / 1.002details
#7ACCEPTED0.32 / 1.002details
#8ACCEPTED0.30 / 1.002details
#9ACCEPTED0.32 / 1.002details
#10ACCEPTED0.30 / 1.002details
#11TIME LIMIT EXCEEDED-- / 1.003details
#12TIME LIMIT EXCEEDED-- / 1.003details
#13ACCEPTED0.49 / 1.003details
#14ACCEPTED0.57 / 1.003details
#15ACCEPTED0.66 / 1.003details

Code

import java.util.*;
import java.math.*;

public class Tehtava3 {

	private static int[][] arvot;
	private static int korkeus;
	private static int leveys;
	private static IO io;
	private static long t;
	private static int pieninKoko;
	private static int ya2;

	
	public static void laskeTavat(int korkeus, int leveys, String[] metsa, int puita) {
		
		
		
		int puitaYhteensa = arvot[leveys-1][korkeus-1];
		
		int maara = 0;
		int maaraAlueella = 0;
		int alaarvo = 0;
		int ylaarvo = 0;
		int valiarvo = 0;
		int valimaksimi = 0;
		int loydettyMaara = 0;
			
		for (int j = 0; j <= leveys - pieninKoko; j++) {
			for (int k = 0; k <= korkeus - pieninKoko; k++) {
				valimaksimi = Math.min(korkeus - k, leveys - j);
				alaarvo = pieninKoko;
				ylaarvo = valimaksimi;
				valiarvo = (ylaarvo + alaarvo) / 2;
				

				// BINAARIHAKU
				maaraAlueella = puidenMaara(j, k, valiarvo);

				
				while (maaraAlueella != puita && alaarvo <= ylaarvo) {
					if (maaraAlueella > puita) {
						ylaarvo = valiarvo - 1;
					} else {
						alaarvo = valiarvo + 1;
					}

					valiarvo = (ylaarvo + alaarvo) / 2;
					maaraAlueella = puidenMaara(j, k, valiarvo);
			
				}
				

				
				for (int d = ylaarvo; d >= alaarvo; d--) {
						loydettyMaara = puidenMaara(j, k, d);

					 if (loydettyMaara == puita) {
						maara++;
					}
					 
					 else if (loydettyMaara < puita) {
							break;
					 }

				}
				

			}
			

		}

		//System.out.println("Kesto: " + (System.currentTimeMillis() - t) + "ms" +", [" + leveys + ", " + korkeus + "], " + puita + ", tulos: " + maara);
		io.print(maara);
	}
	
	
	
	public static int puidenMaara(int alkux, int alkuy, int koko) {

		if (alkux + koko > leveys || alkuy + koko > korkeus)
			return -1;

		int maxx = alkux + koko - 1;
		int maxy = alkuy + koko - 1;

		if (maxx < 0 || maxy < 0)
			return 0;


		int arvo1 = 0;
		int arvo2 = 0;
		int arvo3 = 0;
		int arvo4 = arvot[maxx][maxy];

		if (alkux != 0) {
			arvo3 = arvot[alkux - 1][maxy];
		}

		if (alkuy != 0) {
			arvo2 = arvot[maxx][alkuy - 1];

			if (alkux != 0)
				arvo1 = arvot[alkux - 1][alkuy - 1];
		}
		return (arvo1 + arvo4 - arvo2 - arvo3);

	}

	public static String[] luoSatunnainen(int leveys, int korkeus) {
		StringBuilder sb;
		String[] metsa = new String[korkeus];
		Random r = new Random();
		for (int i = 0; i < korkeus; i++) {
			sb = new StringBuilder();
			for (int j = 0; j < leveys; j++) {
				int a = r.nextInt(10);
				if (a <= 1)
					sb.append('*');
				else
					sb.append('.');

			}

			metsa[i] = sb.toString();
		}

		return metsa;
	}

	public static void tulostaMetsa(String[] metsa) {

		for (int i = 0; i < metsa.length; i++) {
			for (int j = 0; j < metsa[0].length(); j++) {
				System.out.print(metsa[i].charAt(j) + " ");

			}
			System.out.println();
			System.out.println("--------------------------------------");
		}
	}

	public static void luoArvoTaulukko(String[] metsa) {


		int summa1 = 0;
		for (int i = 0; i < leveys; i++) {
			if (metsa[0].charAt(i) == '*') {
				summa1++;
			}
			arvot[i][0] = summa1;
		}

		int summa2 = 0;
		for (int y = 1; y < metsa.length; y++) {
			summa1 = 0;
			summa2 = 0;

			for (int x = 0; x < metsa[0].length(); x++) {

				if (metsa[y].charAt(x) == '*') {
					summa2++;
				}

				summa1 = arvot[x][y - 1];

				arvot[x][y] = (summa1 + summa2);
			}
		}

		// System.out.println("arvotaulukon luontiin meni " +
		// (System.currentTimeMillis()-t1) + "ms");
	}

	public static void main(String[] args) {

		io = new IO();

		 korkeus = io.nextInt();
		 leveys = io.nextInt();
		 int puita = io.nextInt();

		//korkeus = 2000;
		//leveys = 2000;
		//int puita = 1000;

		String[] metsa = new String[korkeus];

		for (int i = 0; i < korkeus; i++) {
			metsa[i] = io.next();
		}

		arvot = new int[leveys][korkeus];

		//metsa = luoSatunnainen(leveys, korkeus);

		//
		// tulostaMetsa(metsa);

		//t = System.currentTimeMillis();

		//
		luoArvoTaulukko(metsa);
		// tulostaMetsa(metsa);

		// tulostaArvoTaulukko();
		pieninKoko = (int) Math.ceil(Math.sqrt(puita));
		

		laskeTavat(korkeus, leveys, metsa, puita);
		// System.out.println("Kesto: " + (System.currentTimeMillis()-t));
		//laskeTavatHidas2(korkeus, leveys, metsa, puita);
		io.close();

	}

}

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
(empty)

Test 12

Group: 3

Verdict: TIME LIMIT EXCEEDED

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

correct output
120725884

view   save

user output
(empty)

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