답안 #115751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115751 2019-06-08T20:14:05 Z fadi57 Topovi (COCI15_topovi) C++14
120 / 120
1627 ms 40120 KB
#include <bits/stdc++.h>
using namespace std;
 

 
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-



ll n,z,k,t,ans,m,l,j;


map<ll,ll>r,c,xr,xc;
map<pair<ll,ll>,ll>h;

ll up(ll x,ll y,ll o){
  
   ans-=(n-(xc[r[x]]));
     ans-=(n-(xr[c[y]]));
     if(r[x]==c[y]){ans++;}
     xr[r[x]]--;
     r[x]^=o; //cout<<r[x]^o;
     xc[c[y]]--; 
     c[y]^=o;
     xr[r[x]]++;
     xc[c[y]]++;
     ans+=(n-(xc[r[x]]));
     ans+=(n-(xr[c[y]]));
 if(r[x]==c[y]){ans--;}
ll kk=9;return kk;
    

}
int main()
{
  
  
ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  cin>>n>>m>>t; 
  xr[0]=xc[0]=n;
  for(ll i=0;i<m;i++){
     ll x,y;
cin>>x>>y>>z; h[{x,y}]=z;

up(x,y,z);
  }

for(ll i=1;i<=t;i++){ 
   ll x,y;
cin>>x>>y>>j>>l;
ll o=h[{x,y}]; h[{x,y}]=0;up(x,y,o);up(j,l,o);
cout<<ans<<endl;h[{j,l}]=o;

  }
  return 0;
  
     

   }
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
6 Correct 202 ms 6444 KB Output is correct
7 Correct 161 ms 5752 KB Output is correct
8 Correct 135 ms 4648 KB Output is correct
9 Correct 125 ms 4728 KB Output is correct
10 Correct 140 ms 5020 KB Output is correct
11 Correct 1594 ms 40120 KB Output is correct
12 Correct 1576 ms 40056 KB Output is correct
13 Correct 1579 ms 40056 KB Output is correct
14 Correct 1584 ms 40060 KB Output is correct
15 Correct 1571 ms 39912 KB Output is correct
16 Correct 1603 ms 39780 KB Output is correct
17 Correct 1577 ms 40088 KB Output is correct
18 Correct 1588 ms 40056 KB Output is correct
19 Correct 1627 ms 39976 KB Output is correct
20 Correct 1623 ms 39968 KB Output is correct