제출 #78784

#제출 시각아이디문제언어결과실행 시간메모리
78784ekremTopovi (COCI15_topovi)C++98
60 / 120
2075 ms66560 KiB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, k, p;
ll ans;
map < int , int > r, c, sr, sc;
map < ii , int > ne;
map < int , int > :: iterator it;

void ekle(int x, int y, int z){
	ne[mp(x, y)] = z;
	ans -= 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]];
	sr[r[x]]--;
	ans += 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]];
	r[x] = r[x]^z;
	ans -= 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]];
	sr[r[x]]++;
	ans += 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]];
	ans -= 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]];
	sc[c[y]]--;
	ans += 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]];
	c[y] = c[y]^z;
	ans -= 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]];
	sc[c[y]]++;
	ans += 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]];
	// for(it = sc.begin(); it != sc.end(); it++)
	// 	ans += 1ll * it->nd * n - 1ll * it->nd * sr[it->st];
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d %d",&n ,&k, &p);
	sr[0] = n;
	sc[0] = n;
	for(int i = 1; i <= k; i++){
		int x, y, z;
		scanf("%d %d %d",&x ,&y ,&z);
		ekle(x, y, z);
	}
	for(int i = 1; i <= p; i++){
		int x, y, z, k;
		scanf("%d %d %d %d",&x ,&y ,&z ,&k);
		int xx = ne[mp(x, y)];
		ekle(x, y, xx);
		ekle(z, k, xx);
		printf("%lld\n", ans);
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

topovi.cpp: In function 'int main()':
topovi.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n ,&k, &p);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x ,&y ,&z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d",&x ,&y ,&z ,&k);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...