Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int adj[5000][5000];
- const int mod = 1e9 + 7;
- int main()
- {
- int v, e, q;
- cin >> v >> e >> q;
- for (int i = 0; i < e; i++)
- {
- int a, b; cin >> a >> b;
- adj[a][b] = 1;
- }
- bool complemented = 0, transposed = 0;
- for (int i = 0; i < q; i++)
- {
- int type; cin >> type;
- if (type == 1) v++;
- else if (type == 2)
- {
- int x, y; cin >> x >> y;
- if (transposed) swap(x, y);
- adj[x][y] = complemented^1;
- }
- else if (type == 3)
- {
- int x; cin >> x;
- for (int j = 0; j < v; j++)
- {
- adj[x][j]= complemented; adj[j][x] = complemented;
- }
- }
- else if (type == 4)
- {
- int x, y; cin >> x >> y;
- if (transposed) swap(x, y);
- adj[x][y] = complemented;
- }
- else if (type == 5) transposed ^= 1;
- else if (type == 6) complemented ^= 1;
- }
- cout << v << endl;
- for (int x = 0; x < v; x++)
- {
- long long out_degree = 0, hash = 0, counter = 1;
- for (int i = 0; i < v; i++)
- {
- if (i == x) continue;
- int cur;
- if (transposed) cur = adj[i][x];
- else cur = adj[x][i];
- if (cur == (complemented^1))
- {
- out_degree++;
- hash += counter * i; hash %= mod;
- counter *= 7; counter %= mod;
- }
- }
- cout << out_degree << " " << hash << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement