結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー nCk_cvnCk_cv
提出日時 2016-07-21 14:28:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 8,425 bytes
コンパイル時間 2,523 ms
コンパイル使用メモリ 94,220 KB
実行使用メモリ 41,560 KB
最終ジャッジ日時 2024-04-23 19:33:25
合計ジャッジ時間 9,404 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 100 ms
39,892 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 113 ms
41,372 KB
testcase_05 AC 114 ms
41,424 KB
testcase_06 AC 102 ms
40,004 KB
testcase_07 AC 102 ms
40,332 KB
testcase_08 AC 108 ms
41,252 KB
testcase_09 AC 117 ms
41,236 KB
testcase_10 AC 105 ms
40,488 KB
testcase_11 WA -
testcase_12 AC 120 ms
41,556 KB
testcase_13 AC 118 ms
41,076 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 116 ms
41,048 KB
testcase_17 AC 125 ms
41,500 KB
testcase_18 AC 114 ms
40,884 KB
testcase_19 AC 111 ms
40,584 KB
testcase_20 AC 121 ms
41,520 KB
testcase_21 AC 120 ms
41,212 KB
testcase_22 AC 110 ms
40,256 KB
testcase_23 AC 106 ms
40,072 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 119 ms
41,320 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 114 ms
41,132 KB
testcase_30 AC 116 ms
41,188 KB
testcase_31 AC 114 ms
40,956 KB
testcase_32 AC 111 ms
40,016 KB
testcase_33 AC 118 ms
41,240 KB
testcase_34 AC 121 ms
41,404 KB
testcase_35 AC 122 ms
41,512 KB
testcase_36 AC 109 ms
40,328 KB
testcase_37 AC 115 ms
41,220 KB
testcase_38 AC 110 ms
41,148 KB
testcase_39 AC 117 ms
41,420 KB
testcase_40 AC 109 ms
40,596 KB
testcase_41 AC 119 ms
41,560 KB
testcase_42 AC 118 ms
41,088 KB
testcase_43 AC 104 ms
40,080 KB
testcase_44 AC 104 ms
40,060 KB
testcase_45 AC 110 ms
40,292 KB
testcase_46 AC 117 ms
41,272 KB
testcase_47 WA -
testcase_48 AC 118 ms
41,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.geom.Point2D;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.*;







class Main {

	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		boolean[] day = new boolean[42];
		char[] in = sc.next().toCharArray();
		for(int i = 0; i < 7; i++) {
			day[14 + i] = (in[i] == 'o')?true:false;
		}
		in = sc.next().toCharArray();
		for(int i = 0; i < 7; i++) {
			day[21 + i] = (in[i] == 'o')?true:false;
		}
		int max = 0;
		for(int i = 0; i < 42; i++) {
			boolean[] cp = Arrays.copyOf(day, day.length);
			for(int j = 0; j < d; j++) {
				if(i + j >= cp.length) break;
				if(cp[i + j]) continue;
				cp[i + j] = true;
			}
			
			for(int j = 0; j < 42; j++) {
				if(!cp[j]) continue;
				for(int k = j; k < 42; k++) {
					if(!cp[k]) {
						max = Math.max(max, k - j);
						break;
					}
				}
			}
			
			
			
		}
		System.out.println(max);
		
		
	}
	static Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
        // ベクトルaの長さをd1/d2倍すると直線bに接するようにd1,d2を設定
        Point a = a2.subtract(a1);
        Point b = b2.subtract(b1);
        double d1 = b.cross(b1.subtract(a1));
        double d2 = b.cross(a);
        if (Math.abs(d1) < EPS && Math.abs(d2) < EPS) return a1;  // same line
        // 同一直線時の線分の交点を考えるなら return intersectsSP(b1,b2,a1) ? a1 : a2; としてはどうか
        if (Math.abs(d2) < EPS) throw new IllegalArgumentException(
                "PRECONDITION NOT SATISFIED");
        return a1.add(a.multiply(d1 / d2));
    }
	static class Data implements Comparable<Data> {
		static Point pp;
		Point s;
		Point t;
		boolean o;
		boolean l;
		double dist;
		Data(Point s, Point t, boolean o, boolean l) {
			this.s = s;
			this.t = t;
			this.o = o;
			this.l = l;
		}
		@Override
		public int compareTo(Data o) {
			if(this.dist < o.dist) return -1;
			if(this.dist > o.dist) return 1;
			return 0;
		}
	}
	static double distanceSP(Point a1, Point a2, Point b) {
        Point r = projection(a1, a2, b);
        // 投影した点が線分上にあるなら、点pからその点への距離を返せばいい
        if (intersectsSP(a1, a2, r)) return r.distance(b);
        return Math.min(b.distance(a1), b.distance(a2));
    }
	static boolean intersectsSP(Point a1, Point a2, Point b) {
        return ccw(a1, a2, b) == 0;
    }
	static Point projection(Point a1, Point a2, Point p) {
        Point a = a2.subtract(a1);
        p = p.subtract(a1);
        double t = a.dot(p) / a.distanceSqr();
        // |a||p|cosθ=t|a|^2, a,tが固定でθが動くとき、点pの軌跡は直線
        return a1.add(a.multiply(t));
    }
	static class Point extends Point2D.Double implements Comparable<Point> {

        public Point() {
        }

        public Point(double x, double y) {
            super(x, y);
            // xとyはfinalではないが、このライブラリ関数の一部は変更されないことを前提としているので注意。
        }

        /** 内積 dot(v1,v2)=|v1||v2|cosθ */
        double dot(Point p) {
            return x * p.x + y * p.y;
        }

        /** 外積 cross(v1,v2)=|v1||v2|sinθ */
        double cross(Point p) {
            return x * p.y - y * p.x;
        }

        double distanceSqr() {
            return x * x + y * y;
        }

        double distance() {
            return Math.hypot(x, y);
        }

        Point add(Point p) {
            return new Point(x + p.x, y + p.y);
        }

        Point multiply(double k) {
            return new Point(k * x, k * y);
        }

        Point multiply(Point p) {  // complex mul: (x+yi)*(p.x+p.yi)
            return new Point(x * p.x - y * p.y, x * p.y + p.x * y);
        }

        Point subtract(Point p) {
            return new Point(x - p.x, y - p.y);
        }

        @Override
        public boolean equals(Object obj) {  // この関数はEclipseで生成して座標の比較だけ書き換えればいい
            if (this == obj) return true;
            if (obj == null) return false;
            if (getClass() != obj.getClass()) return false;
            Point other = (Point) obj;
            if (!approxEquals(x, other.x)) return false;
            if (!approxEquals(y, other.y)) return false;
            return true;
        }

        @Override
        public int compareTo(Point o) {
            if (!approxEquals(x, o.x)) return (int) Math.signum(x - o.x);
            if (!approxEquals(y, o.y)) return (int) Math.signum(y - o.y);
            return 0;
        }

        @Override
        public String toString() {
            return "(" + x + "," + y + ")";
        }

    }
	
	static boolean approxEquals(double a, double b) {
        return Math.abs(a - b) < EPS;
    }
	
	static final double EPS = 1e-12;
	static boolean intersectsSS(Point a1, Point a2, Point b1, Point b2) {
	       // 互いの端点が自身の左右に分かれているならtrue
	       return ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0
	               && ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0;
	}
	 
	 static int ccw(Point a, Point b, Point c) {
	        b = b.subtract(a);
	        c = c.subtract(a);
	        if (b.cross(c) > EPS) return +1;                  // counter clockwise
	        if (b.cross(c) + EPS < 0) return -1;              // clockwise
	        if (b.dot(c) + EPS < 0) return +2;                // c--a--b on line and a!=c
	        if (b.distanceSqr() < c.distanceSqr()) return -2; // a--b--c on line or a==b ※基本的にa==bとなるべきでない 
	        return 0;                                         // a--c--b on line or b==c
	    }


	
	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	        if (!hasNext()) throw new NoSuchElementException();
	        int n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	}
}
0