結果

問題 No.606 カラフルタイル
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-06 00:05:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 2,342 bytes
コンパイル時間 2,561 ms
コンパイル使用メモリ 74,548 KB
実行使用メモリ 61,376 KB
最終ジャッジ日時 2023-08-19 04:37:00
合計ジャッジ時間 9,175 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,376 KB
testcase_01 AC 43 ms
49,404 KB
testcase_02 AC 44 ms
49,288 KB
testcase_03 AC 43 ms
49,436 KB
testcase_04 AC 43 ms
49,440 KB
testcase_05 AC 43 ms
49,448 KB
testcase_06 AC 43 ms
49,308 KB
testcase_07 AC 43 ms
49,444 KB
testcase_08 AC 43 ms
49,576 KB
testcase_09 AC 43 ms
49,324 KB
testcase_10 AC 44 ms
49,408 KB
testcase_11 AC 43 ms
49,392 KB
testcase_12 AC 46 ms
49,668 KB
testcase_13 AC 127 ms
56,600 KB
testcase_14 AC 45 ms
49,720 KB
testcase_15 AC 69 ms
51,116 KB
testcase_16 AC 250 ms
57,716 KB
testcase_17 AC 392 ms
61,376 KB
testcase_18 AC 265 ms
58,028 KB
testcase_19 AC 270 ms
58,148 KB
testcase_20 AC 355 ms
60,368 KB
testcase_21 AC 259 ms
57,220 KB
testcase_22 AC 256 ms
58,252 KB
testcase_23 AC 281 ms
58,440 KB
testcase_24 AC 336 ms
60,396 KB
testcase_25 AC 336 ms
60,192 KB
testcase_26 AC 389 ms
58,740 KB
testcase_27 AC 361 ms
60,500 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