# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
230569 | soroush | Topovi (COCI15_topovi) | C++14 | 2103 ms | 56440 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll ,ll > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn = 1e6+100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);
#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
map < ll , ll > cntstr , cntstn;
map < pii , ll > rook;
map < ll , ll > str , stn;
ll ans = 0;
ll n , k , p;
void add(ll x ,ll y , ll w){
rook[{x , y}]^=w;
ans-=n - cntstn[str[x]];
ans+=ll(str[x]!=stn[y]);
ans -= n - cntstr[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 += n - cntstn[str[x]];
ans += n - cntstr[stn[y]];
}
int main(){
migmig
cin >> n >> k >> p;
cntstr[0] = cntstn[0] = n;
for(ll i = 0 ; i < n; i ++){
ll x , y;
cin >> x >> y;
ll w;
cin >> w;
add(x , y , w);
}
while(p--){
ll x1 , y1 , x2 , y2;
cin >> x1 >> y1 >> x2 >> y2;
ll val = rook[{x1 , y1}];
add(x1 , y1 , val);
add(x2 , y2 , val);
cout << ans << endl;
}
return(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |