# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
230583 | soroush | Topovi (COCI15_topovi) | C++14 | 2102 ms | 45700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <map>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int ,int > pii;
#define endl '\n'
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
map < int , int > cntstr , cntstn;
map < pii , int > rook;
map < int , int > str , stn;
ll ans = 0;
int n , k , p;
void add(int x ,int y , int w){
rook[{x , y}]^=w;
ans+=(cntstn[str[x]] + cntstr[stn[y]]);
ans+=ll(str[x]!=stn[y]);
cntstr[str[x]]--;
cntstn[stn[y]]--;
str[x]^=w;
stn[y]^=w;
cntstr[str[x]]++;
cntstn[stn[y]]++;
ans-=ll(str[x]!=stn[y]);
ans-=(cntstn[str[x]] + cntstr[stn[y]]);
}
int main(){
migmig
cin >> n >> k >> p;
cntstr[0] = cntstn[0] = n;
for(int i = 0 ; i < n; i ++){
int x , y;
cin >> x >> y;
int w;
cin >> w;
add(x , y , w);
}
while(p--){
int x1 , y1 , x2 , y3;
cin >> x1 >> y1 >> x2 >> y3;
int val = rook[{x1 , y1}];
add(x1 , y1 , val);
add(x2 , y3 , val);
cout << ans << endl;
}
return(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |