結果
問題 | No.11 カードマッチ |
ユーザー | mudbdb |
提出日時 | 2015-06-23 02:33:17 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 348 ms |
コンパイル使用メモリ | 21,376 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 19:52:03 |
合計ジャッジ時間 | 932 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:15:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &W); | ^~~~~~~~~~~~~~~ main.c:16:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d", &H); | ^~~~~~~~~~~~~~~ main.c:17:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d", &N); | ^~~~~~~~~~~~~~~ main.c:21:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d", &(S[i])); | ^~~~~~~~~~~~~~~~~~~~ main.c:22:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", &(K[i])); | ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>#include <stdlib.h>int cmp(const void* a, const void* b){return (*(int*)a - *(int*)b);}int main(){int i;int W;int H;int N;int *S;int *K;scanf("%d", &W);scanf("%d", &H);scanf("%d", &N);S = (int*)malloc(sizeof(int)*N);K = (int*)malloc(sizeof(int)*N);for (i=0; i<N; i++) {scanf("%d", &(S[i]));scanf("%d", &(K[i]));}qsort(S, N, sizeof(int), cmp);qsort(K, N, sizeof(int), cmp);int Ws = 1;for (i=0; i<N-1; i++) {if (S[i] != S[i+1]) {Ws++;}}int Hs = 1;for (i=0; i<N-1; i++) {if (K[i] != K[i+1]) {Hs++;}}printf("%d\n", Ws*H + Hs*W - Ws*Hs - N);return 0;}