結果
| 問題 | No.606 カラフルタイル | 
| コンテスト | |
| ユーザー |  夕叢霧香(ゆうむらきりか) | 
| 提出日時 | 2017-12-06 00:05:24 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 405 ms / 2,000 ms | 
| コード長 | 2,342 bytes | 
| コンパイル時間 | 6,402 ms | 
| コンパイル使用メモリ | 77,304 KB | 
| 実行使用メモリ | 49,132 KB | 
| 最終ジャッジ日時 | 2024-11-28 18:12:37 | 
| 合計ジャッジ時間 | 9,151 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
ソースコード
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;
        }
    }
}
            
            
            
        