답안 #502592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502592 2022-01-06T10:09:17 Z Habitus Automobil (COCI17_automobil) C++14
0 / 100
18 ms 460 KB
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dec(x, y) fixed << setprecision((y)) << (x)
#define xx first
#define yy second
#define srt(v) sort((v).begin(), (v).end())
#define srtr(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define popb pop_back
#define sz(a) (int)(a).size()
#define len(a) (int)(a).length()
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod=(ll)1e9+7LL;
ll n, m;
int k;
map<ll, ll> rd, kl;
map<ll, bool> uzrd, uzkl;
ll suma;
int main() {
    ios;
    cin >> n >> m >> k;
    for(int i=0; i<k; i++) {
        char c; ll d, kol;
        cin >> c >> d >> kol;
        if(c=='R') {
            if(!uzrd[d]) rd[d]=kol;
            else rd[d]*=kol;
            uzrd[d]=1;
        }
        else {
            if(!uzkl[d]) kl[d]=kol;
            else kl[d]*=kol;
            uzkl[d]=1;
        }
    }
    suma=(n*m+1LL)*(n*m)/2LL;
    suma%=mod;
    for(auto it=rd.begin(); it!=rd.end(); it++) {
        ll d=it->first, kol=it->second;
        if(uzrd[d]) {suma+=((d*m+1LL)*(d*m)/2LL-((d-1LL)*m+1LL)*((d-1LL)*m)/2LL)*(kol-1LL); suma%=mod;}
    }
    for(auto it=kl.begin(); it!=kl.end(); it++) {
        ll d=it->first, kol=it->second;
        if(uzkl[d]) {suma+=(n*(n-1LL)*m/2LL+d*n)*(kol-1LL); suma%=mod;}
    }
    //cout << suma;
    for(auto it=rd.begin(); it!=rd.end(); it++) {
        for(auto it1=kl.begin(); it1!=kl.end(); it1++) {
            ll d=it->first, kol=it->second;
            ll d1=it1->first, kol1=it1->second;
            if(!uzrd[d] || !uzkl[d1]) continue;
            suma-=(m*(d-1LL)+d1)*(kol+kol1-1LL);
            suma+=(m*(d-1LL)+d1)*kol*kol1;
            suma%=mod;
        }
    }
    cout << suma;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Incorrect 4 ms 332 KB Output isn't correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 2 ms 332 KB Output isn't correct
5 Incorrect 3 ms 332 KB Output isn't correct
6 Incorrect 2 ms 320 KB Output isn't correct
7 Incorrect 6 ms 332 KB Output isn't correct
8 Incorrect 2 ms 332 KB Output isn't correct
9 Incorrect 5 ms 332 KB Output isn't correct
10 Incorrect 7 ms 332 KB Output isn't correct
11 Incorrect 6 ms 332 KB Output isn't correct
12 Incorrect 15 ms 452 KB Output isn't correct
13 Incorrect 4 ms 332 KB Output isn't correct
14 Incorrect 1 ms 204 KB Output isn't correct
15 Incorrect 10 ms 420 KB Output isn't correct
16 Incorrect 15 ms 452 KB Output isn't correct
17 Incorrect 16 ms 460 KB Output isn't correct
18 Incorrect 15 ms 332 KB Output isn't correct
19 Incorrect 18 ms 432 KB Output isn't correct
20 Incorrect 16 ms 312 KB Output isn't correct