結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー ゆきのんゆきのん
提出日時 2020-03-14 02:03:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,457 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 175,028 KB
実行使用メモリ 16,268 KB
最終ジャッジ日時 2023-08-15 10:55:35
合計ジャッジ時間 4,437 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 48 ms
7,152 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 AC 48 ms
4,380 KB
testcase_15 AC 27 ms
4,380 KB
testcase_16 AC 56 ms
8,108 KB
testcase_17 AC 23 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 159 ms
16,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n,m,k;cin >> n >> m >> k;
    char op;cin >> op;
    vector<int> b(m),a(n);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        b[i] %= k;
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= k;
    }
    if(op == '+'){
        map<int,LL> A,B;
        for (int i = 0; i < m; i++) {
            B[b[i]]++;
        }
        LL ans = 0;
        for (int i = 0; i < n; i++) {
            ans += B[(k - a[i])%k];
        }
        cout << ans << endl;
    }
    else{
        LL cntb = 0, cnta = 0;
        for (int i = 0; i < m; i++) {
            if(b[i] == 0) cntb++;
        }
        for (int i = 0; i < m; i++) {
            if(a[i] == 0) cnta++;
        }
        cout << cnta * (m - cntb) + cntb * (n - cnta) - cnta * cntb << endl;

    }
    return 0;
}

0