結果

問題 No.346 チワワ数え上げ問題
ユーザー threepipes_sthreepipes_s
提出日時 2016-02-26 22:28:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 3,142 bytes
コンパイル時間 2,600 ms
コンパイル使用メモリ 93,444 KB
実行使用メモリ 57,296 KB
最終ジャッジ日時 2024-09-22 14:07:15
合計ジャッジ時間 6,608 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
50,436 KB
testcase_01 AC 55 ms
50,428 KB
testcase_02 AC 54 ms
50,344 KB
testcase_03 AC 54 ms
50,328 KB
testcase_04 AC 58 ms
50,264 KB
testcase_05 AC 55 ms
50,452 KB
testcase_06 AC 56 ms
50,492 KB
testcase_07 AC 56 ms
50,036 KB
testcase_08 AC 56 ms
50,560 KB
testcase_09 AC 58 ms
50,192 KB
testcase_10 AC 185 ms
56,780 KB
testcase_11 AC 160 ms
56,212 KB
testcase_12 AC 168 ms
57,184 KB
testcase_13 AC 156 ms
56,552 KB
testcase_14 AC 92 ms
51,484 KB
testcase_15 AC 171 ms
56,740 KB
testcase_16 AC 180 ms
56,932 KB
testcase_17 AC 189 ms
57,296 KB
testcase_18 AC 174 ms
57,152 KB
testcase_19 AC 180 ms
57,120 KB
testcase_20 AC 182 ms
57,064 KB
testcase_21 AC 188 ms
57,284 KB
testcase_22 AC 188 ms
57,100 KB
testcase_23 AC 55 ms
50,276 KB
testcase_24 AC 55 ms
50,400 KB
testcase_25 AC 55 ms
50,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
 
public class Main {
	public static void main(String[] args) throws NumberFormatException,
	IOException {Solve solve = new Solve();solve.solve();}
}
class Solve{
	void dump(int[]a){for(int i=0;i<a.length;i++)System.out.print(a[i]+" ");System.out.println();}
	void dump(int[]a,int n){for(int i=0;i<a.length;i++)System.out.printf("%"+n+"d",a[i]);System.out.println();}
	void dump(long[]a){for(int i=0;i<a.length;i++)System.out.print(a[i]+" ");System.out.println();}
	void dump(char[]a){for(int i=0;i<a.length;i++)System.out.print(a[i]);System.out.println();}
	String itob(int a,int l){return String.format("%"+l+"s",Integer.toBinaryString(a)).replace(' ','0');}
	void solve() throws NumberFormatException, IOException{
		final ContestScanner in = new ContestScanner();
		Writer out = new Writer();
		char[] s = in.nextToken().toCharArray();
		long[] dp = new long[3];
		for(int i=0; i<s.length; i++){
			long[] newdp = new long[3];
			if(s[i]=='c'){
				dp[0]++;
			}else if(s[i]=='w'){
				dp[2] += dp[1];
				dp[1] += dp[0];
			}
		}
		System.out.println(dp[2]);
	}
}

class MultiSet<T> extends HashMap<T, Integer>{
	@Override
	public Integer get(Object key){return containsKey(key)?super.get(key):0;}
	public void add(T key,int v){put(key,get(key)+v);}
	public void add(T key){put(key,get(key)+1);}
	public void sub(T key)
	{final int v=get(key);if(v==1)remove(key);else put(key,v-1);}
}
class Timer{
	long time;
	public void set(){time=System.currentTimeMillis();}
	public long stop(){return time=System.currentTimeMillis()-time;}
	public void print()
	{System.out.println("Time: "+(System.currentTimeMillis()-time)+"ms");}
	@Override public String toString(){return"Time: "+time+"ms";}
}
class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner {
	private InputStreamReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new InputStreamReader(System.in);}
	public ContestScanner(String filename)throws IOException
	{in=new InputStreamReader(new FileInputStream(filename));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
}
0