답안 #98658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98658 2019-02-25T02:51:08 Z HellAngel Topovi (COCI15_topovi) C++14
120 / 120
1308 ms 41140 KB
#include <bits/stdc++.h>
#define int long long
#define y1 concac
using namespace std;
unordered_map<int, int> row, col,cntrow, cntcol, valrow, valcol;
map<pair<int, int>, int> hihi;
int n, k, p;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    cin >> n >> k >> p;
    for(int i = 1; i <= k; i++)
    {
        int u, v, c;
        cin >> u >> v >> c;
        row[u] ^= c;
        col[v] ^= c;
        cntrow[u]++;
        cntcol[v]++;
        hihi[{u, v}] = c;
    }
    valrow[0] = n - cntrow.size();
    valcol[0] = n - cntcol.size();
    int ans = (n - cntrow.size()) * (n - cntcol.size());
    for(auto i: row)
    {
        int gau = i.first;
        int meo = i.second;
        valrow[i.second]++;
        if(valcol.find(i.second) != valcol.end()) ans += valcol[i.second];
    }
    for(auto i: col)
    {
        int gau = i.first;
        int meo = i.second;
        valcol[i.second]++;
        if(valrow.find(i.second) != valrow.end()) ans += valrow[i.second];
    }
    for(int i = 1; i <= p; i++)
    {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int val = hihi[{x1, y1}];
        hihi.erase(hihi.find({x1, y1}));
        hihi[{x2, y2}] = val;

        int oldrow = row[x1];
        cntrow[x1]--;
        valrow[oldrow]--;
        ans -= valcol[oldrow];
        row[x1] ^= val;
        int newrow = oldrow ^ val;
        valrow[newrow]++;
        ans += valcol[newrow];

        oldrow = row[x2];
        cntrow[x2]++;
        valrow[oldrow]--;
        ans -= valcol[oldrow];
        newrow = oldrow ^ val;
        row[x2] ^= val;
        valrow[newrow]++;
        ans += valcol[newrow];

        int oldcol = col[y1];
        cntcol[y1]--;
        valcol[oldcol]--;
        ans -= valrow[oldcol];
        col[y1] ^= val;
        int newcol = oldcol ^ val;
        valcol[newcol]++;
        ans += valrow[newcol];


        oldcol = col[y2];
        cntcol[y2]++;
        valcol[oldcol]--;
        ans -= valrow[oldcol];
        newcol = oldcol ^= val;
        col[y2] ^= val;
        valcol[newcol]++;
        ans += valrow[newcol];

        cout << n * n - ans << '\n';
    }
}

Compilation message

topovi.cpp: In function 'int32_t main()':
topovi.cpp:30:13: warning: unused variable 'gau' [-Wunused-variable]
         int gau = i.first;
             ^~~
topovi.cpp:31:13: warning: unused variable 'meo' [-Wunused-variable]
         int meo = i.second;
             ^~~
topovi.cpp:37:13: warning: unused variable 'gau' [-Wunused-variable]
         int gau = i.first;
             ^~~
topovi.cpp:38:13: warning: unused variable 'meo' [-Wunused-variable]
         int meo = i.second;
             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 144 ms 7076 KB Output is correct
7 Correct 129 ms 7004 KB Output is correct
8 Correct 77 ms 5244 KB Output is correct
9 Correct 81 ms 5216 KB Output is correct
10 Correct 82 ms 5296 KB Output is correct
11 Correct 1252 ms 40944 KB Output is correct
12 Correct 1308 ms 40948 KB Output is correct
13 Correct 1214 ms 41012 KB Output is correct
14 Correct 1289 ms 41092 KB Output is correct
15 Correct 1071 ms 41000 KB Output is correct
16 Correct 1178 ms 40940 KB Output is correct
17 Correct 1127 ms 40912 KB Output is correct
18 Correct 1256 ms 41036 KB Output is correct
19 Correct 1174 ms 41072 KB Output is correct
20 Correct 1172 ms 41140 KB Output is correct