結果

問題 No.945 YKC饅頭
ユーザー kitakitalilykitakitalily
提出日時 2019-12-08 21:23:16
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 6,835 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 78,512 KB
実行使用メモリ 114,476 KB
最終ジャッジ日時 2023-08-30 06:00:16
合計ジャッジ時間 33,580 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
56,560 KB
testcase_01 AC 79 ms
56,604 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 86 ms
56,604 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 94 ms
56,708 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 117 ms
58,008 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 122 ms
58,056 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 106 ms
57,876 KB
testcase_28 AC 110 ms
57,652 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 324 ms
66,356 KB
testcase_32 AC 545 ms
81,744 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 WA -
testcase_40 AC 561 ms
83,452 KB
testcase_41 AC 547 ms
79,072 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 365 ms
73,696 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 AC 540 ms
83,628 KB
testcase_50 RE -
testcase_51 RE -
testcase_52 AC 1,030 ms
112,200 KB
testcase_53 RE -
testcase_54 RE -
testcase_55 WA -
testcase_56 AC 436 ms
84,452 KB
testcase_57 AC 274 ms
77,244 KB
testcase_58 RE -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 RE -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 RE -
testcase_68 RE -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
	static int size = 200000;
	static long[] fac = new long[size];
	static long[] finv = new long[size];
	static long[] inv = new long[size];
	static int mod = 1000000007;
	static int INF = Integer.MAX_VALUE;
 	public static void main(String[] args){
		FastScanner scanner = new FastScanner();
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];
		String[] s = new String[m];
		for(int i = 0; i < m; i++){
			l[i] = scanner.nextInt()-1;
			r[i] = scanner.nextInt()-1;
			s[i] = scanner.next();
		}
		TreeSet<Integer> set = new TreeSet<Integer>();
		for(int i = 0; i < n; i++){
			set.add(i);
		}
		TreeSet<Integer> rm = new TreeSet<Integer>();
		String[] ans = new String[n];
		for(int i = 0; i < m; i++){
			int it = set.higher(l[i])-1;
			if(it == -1) continue;
			while(it <= r[i] && !set.isEmpty()){
				if(!rm.contains(it)){
					rm.add(it);
					ans[it] = s[i];
				}
				set.remove(it);
				it++;
			}
			//System.out.println(set);
		}
		int cnty = 0; int cntk = 0; int cntc = 0;
		for(int i = 0; i < n; i++){
			if(ans[i] == null) continue;
			if(ans[i].equals("Y")){
				cnty++;
			}else if(ans[i].equals("K")){
				cntk++;
			}else if(ans[i].equals("C")){
				cntc++;
			}
		}
		System.out.println(cnty+ " " + cntk + " " + cntc);
	}
	//繰り返し二乗法
	public static long pow(long x, long n){
		long ans = 1;
		while(n > 0){
			if((n & 1) == 1){
				ans = ans * x;
				ans %= mod;
			}
			x = x * x % mod;
			n >>= 1;
		}
		return ans;
	}
	public static long div(long x, long y){
		return (x*pow(y, mod-2))%mod;
	}
	//fac, inv, finvテーブルの初期化、これ使う場合はinitComb()で初期化必要
	public static  void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < size; ++i) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = mod - (mod / i) * inv[(int) (mod % i)] % mod;
			finv[i] = finv[i - 1] * inv[i] % mod;
		}
	}
	//nCk % mod
	public static long comb(int n, int k){
		return fac[n] * finv[k] % mod * finv[n - k] % mod;
	}
	//n! % mod
	public static long fact(int n){
		return fac[n];
	}
	//(n!)^-1 with % mod
	public static long finv(int n){
		return finv[n];
	}
	/**
	 * 0-indexed BinaryIndexTree
	 * 区間加算あり
	 * */
	static class BIT {
		private int n;
	  private long[] bit;

		public BIT(int n) {
			this.n = n;
			bit = new long[n + 2];
		}

		public void accumulate(int begin, int end, long num) {
			accumulate(begin, num);
			accumulate(end, -num);
		}

		private void accumulate(int index, long num) {
			index++;
			while (index <= n + 1) {
				bit[index] += num;
				index += index & -index;
			}
		}

		private long sum(int i) {
			long s = 0;
			while (i > 0) {
				s += bit[i];
				i -= i & -i;
			}
			return s;
		}

		public long get(int index) {
			return sum(index + 1);
		}

		public void set(int index, long num) {
			accumulate(index, index + 1, num - get(index));
		}

		public String toString() {
			long[] value = new long[n];
			for (int i = 0; i < n; i++) {
				value[i] = get(i);
			}
			return Arrays.toString(value);
		}
	}
	static class Pair implements Comparable<Pair>{
    int first, second;
    Pair(int a, int b){
        first = a;
        second = b;
    }
    @Override
    public boolean equals(Object o){
        if (this == o) return true;
        if (!(o instanceof Pair)) return false;
        Pair p = (Pair) o;
        return first == p.first && second == p.second;
    }
    @Override
    public int compareTo(Pair p){
        return first == p.first ? second - p.second : first - p.first; //firstで昇順にソート
        //return (first == p.first ? second - p.second : first - p.first) * -1; //firstで降順にソート
        //return second == p.second ? first - p.first : second - p.second;//secondで昇順にソート
        //return (second == p.second ? first - p.first : second - p.second)*-1;//secondで降順にソート
		    //return first * 1.0 / second > p.first * 1.0 / p.second ? 1 : -1; // first/secondの昇順にソート
		    //return first * 1.0 / second < p.first * 1.0 / p.second ? 1 : -1; // first/secondの降順にソート
				//return second * 1.0 / first > p.second * 1.0 / p.first ? 1 : -1; // second/firstの昇順にソート
		    //return second * 1.0 / first < p.second * 1.0 / p.first ? 1 : -1; // second/firstの降順にソート
				//return Math.atan2(second, first) > Math.atan2(p.second, p.first) ? 1 : -1; // second/firstの昇順にソート
				//return first + second > p.first + p.second ? 1 : -1; //first+secondの昇順にソート
				//return first + second < p.first + p.second ? 1 : -1; //first+secondの降順にソート
				//return first - second < p.first - p.second ? 1 : -1; //first-secondの降順にソート
				//return second - first < p.second - p.first ? -1 : 1; //second-firstの昇順にソート
				//return Math.atan2(second,first) > Math.atan2(p.second, p.first) ? 1 : -1;
		}
  }

	private 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;}
		public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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() {
				long nl = nextLong();
				if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
				return (int) nl;
		}
		public double nextDouble() { return Double.parseDouble(next());}
	}
}
0