CSES - Datatähti 2018 alku - Results
Submission details
Task:Fraktaali
Sender:RoniTuohino
Submission time:2017-10-04 15:38:35 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
#60
#70
#80
#90
#100
Test results
testverdicttimegroup
#10.13 s1details
#20.15 s2details
#30.14 s3details
#40.12 s4details
#50.11 s5details
#60.13 s6details
#70.12 s7details
#80.12 s8details
#90.11 s9details
#100.12 s10details

Code

package com.company;

import java.util.*;
public class Main {
    public static void main(String[] args) {
	    Scanner s = new Scanner(System.in);
	    int f = s.nextInt();
	    int size = (int)CalculateSize(f);

		char[][]startFrac = new char[size][size];

		for (int x = 0; x < startFrac.length; x++){	//Turn all spaces black '#'
			for (int y = 0; y < startFrac.length; y++){
				startFrac[x][y] = '#';
			}
		}

		startFrac = BuildFractal(startFrac, size, f);
		PrintFractal(startFrac);
    }

    public  static  double CalculateSize(double x){		//Calculate the size for the fractal
    	if(x == 1){
    		x = 1;
		} else if(x == 2){
    		x = 2;
		} else if(x == 3){
			x = 4;
		} else if(x == 4){
			x = 8;
		} else if(x >= 5){
			x = Math.pow(2, x-1);
		}
    	return  x;
	}

	public static char[][] BuildFractal(char[][] frac, int size, int f){ //Build the final fractal
    	char[][] finalFrac;

    	finalFrac = frac;

		if(f == 1){
			return finalFrac;
		}

		finalFrac[1][1] = '.';	//First white piece on the corner
		if(f == 2){
			return finalFrac;
		}

		for(int i = 2; i < f; i++){	//Do this loop until fractal is complete
			//Insert all the corners of the fractal
			finalFrac = SetTheCorners(finalFrac, (int)CalculateSize(i+1) ,(int)CalculateSize(i));

		}

		return finalFrac;
	}

	public  static  char[][] SetTheCorners(char[][] frac, int size, int pos){	//Set the on the fractal
		char[][] finalFrac = frac;
		char[][] copy = new char[pos][pos];
		//System.out.println(pos);
		for(int x = 0; x < pos; x++){	//Copy is now the corner to set
			for(int y = 0; y < pos; y++){
				copy[x][y] = finalFrac[x][y];
			}
		}

		for(int x = 0; x <= pos - 1; x++){	//Set the first corner on the top right
			for(int y = pos; y <= size - 1; y++){
				if(copy[x][y - pos] == '.'){
					finalFrac[x][y] = '.';
				}
			}
		}

		for(int x = pos; x <= size - 1; x++){	//Set the second corner on the bottom left
			for(int y = 0; y <= pos - 1; y++){
				if(copy[x - pos][y] == '.'){
					finalFrac[x][y] = '.';
				}
			}
		}

		for(int x = pos; x <= size - 1; x++){	//Scans the bottom right negative
			for(int y = pos; y <= size - 1; y++){
				//finalFrac[x][y] = '.';
				if(copy[x - pos][y - pos] == '#'){
					finalFrac[x][y] = '.';
				}
				else if(copy[x - pos][y - pos] == '.'){
					finalFrac[x][y] = '#';
				}
			}
		}
		return finalFrac;
	}

    public static void PrintFractal(char[][] frac){	//Print the fractal
		for (int x = 0; x < frac.length; x++){
			System.out.println("");
			for(int y=0; y < frac.length; y++){
				System.out.print(frac[x][y]);
			}
		}
	}
}

Test details

Test 1

Group: 1

Verdict:

input
1

correct output
#

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 2

Group: 2

Verdict:

input
2

correct output
##
#.

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 3

Group: 3

Verdict:

input
3

correct output
####
#.#.
##..
#..#

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 4

Group: 4

Verdict:

input
4

correct output
########
#.#.#.#.
##..##..
#..##..#
####....
...

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 5

Group: 5

Verdict:

input
5

correct output
################
#.#.#.#.#.#.#.#.
##..##..##..##..
#..##..##..##..#
####....####....
...

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 6

Group: 6

Verdict:

input
6

correct output
##############################...

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 7

Group: 7

Verdict:

input
7

correct output
##############################...

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 8

Group: 8

Verdict:

input
8

correct output
##############################...

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 9

Group: 9

Verdict:

input
9

correct output
##############################...

user output
(empty)

Error:
Error: Could not find or load main class Main

Test 10

Group: 10

Verdict:

input
10

correct output
##############################...

user output
(empty)

Error:
Error: Could not find or load main class Main