結果

問題 No.3110 Like CPCTF?
ユーザー 37zigen
提出日時 2025-04-19 00:35:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 978 bytes
コンパイル時間 5,567 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 55,804 KB
最終ジャッジ日時 2025-04-19 00:35:15
合計ジャッジ時間 7,388 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 512 * 1024 * 1024).start();
    }
    
    char[] cs;
    int ans=0;
    
    void dfs(int id, int len, char[] w) {
    	if (len==5) {
    		boolean ok=true;
    		for(int i=0;i<w.length;++i) {
    			for(int j=i+1;j<w.length;++j) {
    				ok&=(i==0&&j==2)==(w[i]==w[j]);
    			}
    		}
    		if(ok)++ans;
    		return;
    	}
    	if(id>=cs.length)return;
    	dfs(id+1,len,w);
    	w[len]=cs[id];
    	dfs(id+1,len+1,w);
    }
    
    public void run() {
    	Scanner sc=new Scanner(System.in);
    	int n=sc.nextInt();
    	cs=sc.next().toCharArray();
    	dfs(0, 0, new char[5]);
    	System.out.println(ans);
    }
    
    void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}
0