답안 #98624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98624 2019-02-25T02:01:45 Z minhtung0404 Topovi (COCI15_topovi) C++17
60 / 120
2000 ms 33768 KB
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;

typedef pair <int, int> ii;
map <int, int> mp[2], val[2];
map <ii, int> ro;
int n, k, p;
long long ans;

void add(int i, int num, int x){
    ans += 1LL * mp[0][val[i][num]] * mp[1][val[i][num]];
    mp[i][val[i][num]]--;
    ans -= 1LL * mp[0][val[i][num]] * mp[1][val[i][num]];

    val[i][num] ^= x;

    ans += 1LL * mp[0][val[i][num]] * mp[1][val[i][num]];
    mp[i][val[i][num]]++;
    ans -= 1LL * mp[0][val[i][num]] * mp[1][val[i][num]];
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k >> p;
    mp[0][0] = mp[1][0] = n;
    while (k--){
        int r, c, x;
        cin >> r >> c >> x;
        add(0, r, x); add(1, c, x);
        ro[ii(r,c)] = x;
    }
    while (p--){
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;
        int x = ro[ii(r1,c1)];
        ro[ii(r1,c1)] = 0; ro[ii(r2,c2)] = x;
        add(0, r1, x); add(1, c1, x);
        add(0, r2, x); add(1, c2, x);
        cout << ans << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 270 ms 5368 KB Output is correct
7 Correct 231 ms 4856 KB Output is correct
8 Correct 181 ms 3932 KB Output is correct
9 Correct 164 ms 4088 KB Output is correct
10 Correct 189 ms 4216 KB Output is correct
11 Execution timed out 2035 ms 33752 KB Time limit exceeded
12 Execution timed out 2019 ms 33768 KB Time limit exceeded
13 Execution timed out 2020 ms 33596 KB Time limit exceeded
14 Execution timed out 2017 ms 33540 KB Time limit exceeded
15 Execution timed out 2033 ms 33604 KB Time limit exceeded
16 Execution timed out 2061 ms 33116 KB Time limit exceeded
17 Execution timed out 2027 ms 33472 KB Time limit exceeded
18 Execution timed out 2008 ms 33352 KB Time limit exceeded
19 Execution timed out 2103 ms 32748 KB Time limit exceeded
20 Execution timed out 2041 ms 33680 KB Time limit exceeded