Submission #7536161


Source Code Expand

Copy
import java.util.*;
import java.lang.*;



public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int shortEnough = 0, tooLong=N/2+1;

        while(shortEnough+1<tooLong){
            int trial = (shortEnough+tooLong)/2;
            boolean found = false;

            Map<String, Integer> dic = new HashMap<>();
            for(int l=0; l<N-trial; l++){
                String current = S.substring(l,l+trial);
                if(dic.containsKey(current) && dic.get(current)<l-trial){
                    found = true;
                    break;
                }else{
                    dic.putIfAbsent(current, l);
                }
            }

            if(found) shortEnough = trial;
            else tooLong = trial;
        }
        System.out.println(shortEnough);
    }
}

Submission Info

Submission Time
Task E - Who Says a Pun?
User NASU41
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 946 Byte
Status WA
Exec Time 287 ms
Memory 108452 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 1
WA × 2
AC × 57
WA × 13
Set Name Test Cases
Sample 00-sample-00, 00-sample-01, 00-sample-02
All 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 01-handmade-07, 01-handmade-08, 01-handmade-09, 01-handmade-10, 01-handmade-11, 01-handmade-12, 02-binary-13, 02-binary-14, 02-binary-15, 02-binary-16, 02-binary-17, 02-binary-18, 02-binary-19, 02-binary-20, 02-binary-21, 02-binary-22, 02-binary-23, 03-BigRandom-24, 03-BigRandom-25, 03-BigRandom-26, 03-BigRandom-27, 03-BigRandom-28, 03-BigRandom-29, 03-BigRandom-30, 03-BigRandom-31, 03-BigRandom-32, 03-BigRandom-33, 03-BigRandom-34, 03-BigRandom-35, 03-BigRandom-36, 03-BigRandom-37, 03-BigRandom-38, 03-BigRandom-39, 03-BigRandom-40, 03-BigRandom-41, 03-BigRandom-42, 03-BigRandom-43, 03-BigRandom-44, 03-BigRandom-45, 03-BigRandom-46, 03-BigRandom-47, 03-BigRandom-48, 03-BigRandom-49, 03-BigRandom-50, 03-BigRandom-51, 03-BigRandom-52, 03-BigRandom-53, 03-BigRandom-54, 04-zero-55, 04-zero-56, 05-AllRandom-57, 05-AllRandom-58, 05-AllRandom-59, 05-AllRandom-60, 05-AllRandom-61, 05-AllRandom-62, 05-AllRandom-63, 05-AllRandom-64, 05-AllRandom-65, 05-AllRandom-66, 05-AllRandom-67, 05-AllRandom-68, 05-AllRandom-69
Case Name Status Exec Time Memory
00-sample-00 WA 94 ms 21844 KB
00-sample-01 AC 97 ms 21716 KB
00-sample-02 WA 94 ms 21716 KB
01-handmade-03 WA 287 ms 58736 KB
01-handmade-04 AC 283 ms 108452 KB
01-handmade-05 WA 251 ms 90560 KB
01-handmade-06 WA 239 ms 89476 KB
01-handmade-07 WA 252 ms 79812 KB
01-handmade-08 WA 266 ms 59604 KB
01-handmade-09 WA 183 ms 44236 KB
01-handmade-10 WA 186 ms 44572 KB
01-handmade-11 WA 238 ms 65492 KB
01-handmade-12 AC 226 ms 74708 KB
02-binary-13 AC 159 ms 35924 KB
02-binary-14 AC 173 ms 36648 KB
02-binary-15 AC 159 ms 38868 KB
02-binary-16 AC 179 ms 43264 KB
02-binary-17 AC 180 ms 38220 KB
02-binary-18 AC 174 ms 36764 KB
02-binary-19 AC 150 ms 32980 KB
02-binary-20 AC 160 ms 37204 KB
02-binary-21 AC 157 ms 34644 KB
02-binary-22 AC 154 ms 32340 KB
02-binary-23 AC 136 ms 33748 KB
03-BigRandom-24 AC 228 ms 73228 KB
03-BigRandom-25 AC 236 ms 73836 KB
03-BigRandom-26 AC 213 ms 62456 KB
03-BigRandom-27 AC 245 ms 83216 KB
03-BigRandom-28 AC 243 ms 77324 KB
03-BigRandom-29 AC 247 ms 79980 KB
03-BigRandom-30 WA 241 ms 70000 KB
03-BigRandom-31 AC 238 ms 73796 KB
03-BigRandom-32 AC 259 ms 86204 KB
03-BigRandom-33 AC 233 ms 85352 KB
03-BigRandom-34 AC 250 ms 80280 KB
03-BigRandom-35 AC 227 ms 78396 KB
03-BigRandom-36 AC 229 ms 77596 KB
03-BigRandom-37 AC 225 ms 70556 KB
03-BigRandom-38 AC 250 ms 81052 KB
03-BigRandom-39 WA 229 ms 76284 KB
03-BigRandom-40 AC 222 ms 82116 KB
03-BigRandom-41 AC 245 ms 85328 KB
03-BigRandom-42 AC 258 ms 77160 KB
03-BigRandom-43 WA 235 ms 68148 KB
03-BigRandom-44 AC 235 ms 72504 KB
03-BigRandom-45 AC 225 ms 79132 KB
03-BigRandom-46 AC 223 ms 84504 KB
03-BigRandom-47 AC 257 ms 81812 KB
03-BigRandom-48 AC 233 ms 75364 KB
03-BigRandom-49 AC 225 ms 65728 KB
03-BigRandom-50 AC 253 ms 81212 KB
03-BigRandom-51 AC 244 ms 77848 KB
03-BigRandom-52 AC 236 ms 79132 KB
03-BigRandom-53 AC 248 ms 77752 KB
03-BigRandom-54 AC 256 ms 82152 KB
04-zero-55 AC 95 ms 21716 KB
04-zero-56 AC 95 ms 19540 KB
05-AllRandom-57 AC 182 ms 42428 KB
05-AllRandom-58 AC 178 ms 42116 KB
05-AllRandom-59 AC 176 ms 44020 KB
05-AllRandom-60 AC 182 ms 40228 KB
05-AllRandom-61 AC 178 ms 33916 KB
05-AllRandom-62 AC 180 ms 37152 KB
05-AllRandom-63 AC 165 ms 40020 KB
05-AllRandom-64 AC 179 ms 38264 KB
05-AllRandom-65 AC 183 ms 36688 KB
05-AllRandom-66 AC 179 ms 36140 KB
05-AllRandom-67 AC 178 ms 34364 KB
05-AllRandom-68 AC 175 ms 45240 KB
05-AllRandom-69 AC 185 ms 45136 KB