Submission #501926

# Submission time Handle Problem Language Result Execution time Memory
501926 2022-01-04T19:35:28 Z Habitus Automobil (COCI17_automobil) C++14
0 / 100
15 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;

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;
    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);
    }
    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);
    }
    //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-1)+d1)*(kol+kol1-1);
            suma+=(m*(d-1)+d1)*kol*kol1;
        }
    }
    cout << suma;
  	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Incorrect 5 ms 316 KB Output isn't correct
3 Incorrect 1 ms 332 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 316 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 6 ms 332 KB Output isn't correct
11 Incorrect 5 ms 332 KB Output isn't correct
12 Incorrect 13 ms 444 KB Output isn't correct
13 Incorrect 3 ms 332 KB Output isn't correct
14 Incorrect 0 ms 204 KB Output isn't correct
15 Incorrect 9 ms 332 KB Output isn't correct
16 Incorrect 15 ms 332 KB Output isn't correct
17 Incorrect 15 ms 460 KB Output isn't correct
18 Incorrect 14 ms 388 KB Output isn't correct
19 Incorrect 14 ms 456 KB Output isn't correct
20 Incorrect 15 ms 332 KB Output isn't correct