답안 #98654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98654 2019-02-25T02:48:58 Z HellAngel Topovi (COCI15_topovi) C++14
90 / 120
2000 ms 58940 KB
#include <bits/stdc++.h>
#define int long long
#define y1 concac
using namespace std;
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 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 200 ms 8876 KB Output is correct
7 Correct 159 ms 8312 KB Output is correct
8 Correct 125 ms 6904 KB Output is correct
9 Correct 133 ms 6984 KB Output is correct
10 Correct 145 ms 7096 KB Output is correct
11 Correct 1928 ms 58744 KB Output is correct
12 Correct 1911 ms 58780 KB Output is correct
13 Correct 1961 ms 58756 KB Output is correct
14 Correct 1914 ms 58940 KB Output is correct
15 Execution timed out 2033 ms 58812 KB Time limit exceeded
16 Execution timed out 2040 ms 58676 KB Time limit exceeded
17 Execution timed out 2049 ms 58676 KB Time limit exceeded
18 Correct 1987 ms 58612 KB Output is correct
19 Execution timed out 2053 ms 58832 KB Time limit exceeded
20 Execution timed out 2025 ms 58648 KB Time limit exceeded