結果
問題 | No.1225 I hate I hate Matrix Construction |
ユーザー |
|
提出日時 | 2020-09-13 01:16:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 509 bytes |
コンパイル時間 | 1,707 ms |
コンパイル使用メモリ | 193,900 KB |
最終ジャッジ日時 | 2025-01-14 14:17:41 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | rep(i,n) scanf("%d",&r[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(i,n) scanf("%d",&c[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n; scanf("%d",&n); vector<int> r(n),c(n); rep(i,n) scanf("%d",&r[i]); rep(i,n) scanf("%d",&c[i]); int rcnt[3]={},ccnt[3]={}; rep(i,n){ rcnt[r[i]]++; ccnt[c[i]]++; } int ans=rcnt[2]*n+ccnt[2]*n-rcnt[2]*ccnt[2]; if(rcnt[2]==0 && ccnt[2]==0){ ans+=max(rcnt[1],ccnt[1]); } else if(rcnt[2]==0){ ans+=ccnt[1]; } else if(ccnt[2]==0){ ans+=rcnt[1]; } printf("%d\n",ans); return 0; }