結果

問題 No.606 カラフルタイル
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-06 00:05:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 2,342 bytes
コンパイル時間 2,628 ms
コンパイル使用メモリ 77,680 KB
実行使用メモリ 49,312 KB
最終ジャッジ日時 2024-05-06 11:48:45
合計ジャッジ時間 9,388 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,216 KB
testcase_01 AC 54 ms
37,204 KB
testcase_02 AC 52 ms
37,248 KB
testcase_03 AC 54 ms
37,144 KB
testcase_04 AC 54 ms
37,256 KB
testcase_05 AC 54 ms
37,136 KB
testcase_06 AC 56 ms
37,220 KB
testcase_07 AC 55 ms
37,284 KB
testcase_08 AC 53 ms
37,216 KB
testcase_09 AC 53 ms
36,760 KB
testcase_10 AC 53 ms
36,844 KB
testcase_11 AC 53 ms
37,068 KB
testcase_12 AC 54 ms
37,220 KB
testcase_13 AC 141 ms
43,060 KB
testcase_14 AC 52 ms
37,256 KB
testcase_15 AC 90 ms
38,436 KB
testcase_16 AC 256 ms
47,652 KB
testcase_17 AC 392 ms
48,932 KB
testcase_18 AC 276 ms
47,840 KB
testcase_19 AC 263 ms
47,824 KB
testcase_20 AC 389 ms
48,864 KB
testcase_21 AC 274 ms
46,472 KB
testcase_22 AC 278 ms
47,832 KB
testcase_23 AC 322 ms
48,104 KB
testcase_24 AC 369 ms
48,880 KB
testcase_25 AC 378 ms
49,164 KB
testcase_26 AC 395 ms
49,000 KB
testcase_27 AC 386 ms
49,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int k=sc.nextInt();
        int q=sc.nextInt();
        char[]a=new char[q];
        int[]b=new int[q],c=new int[q];
        long[]ans=new long[k];
        boolean[]row=new boolean[n],col=new boolean[n];
        int nr=n,nc=n;
        for(int i=0;i<q;++i){
            a[i]=sc.next().charAt(0);
            b[i]=sc.nextInt()-1;
            c[i]=sc.nextInt()-1;
        }
        for(int i=q-1;i>=0;--i){
            if(a[i]=='R'){
                if(row[b[i]])continue;
                ans[c[i]]+=nc;
                nr--;
                row[b[i]]=true;
            }else{
                if(col[b[i]])continue;
                ans[c[i]]+=nr;
                nc--;
                col[b[i]]=true;
            }
        }
        ans[0]=(long)n*(long)n;
        for(int i=1;i<k;++i)ans[0]-=ans[i];
        for(long aa:ans)out.println(aa);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
0