QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#101584#6379. LaLa and Monster Hunting (Part 2)zhoukangyang#WA 3ms4488kbC++173.0kb2023-04-30 13:43:192023-04-30 13:43:21

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-30 13:43:21]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4488kb
  • [2023-04-30 13:43:19]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsigned int
#define ull unsigned long long 
#define bs bitset < N >
using namespace std;
const int N = 2e4 + 7, mod = 998244353;
int n, m;
vi G[N];
vi ve[N];
int vis[N];
int dak[N][4];

unordered_map < ll, int > MP; 

inline ll getid(int x, int y) {
	if(x > y) swap(x, y);
	return (ll) x * n + y;
}

bitset < N > S[N], le[N / 2], re[N / 2]; 

int w2[N], w3[N], me[N];
int eu[N], ev[N];
int ans = 0;
inline void cyc(int x, int y, int z, int exy, int eyz, int ezx) {
	(ans += dak[x][3]) %= mod;
	(ans += mod - w3[ezx]) %= mod;
	(ans += mod - w3[exy]) %= mod;
	(ans += mod - me[x]) %= mod;
//	cout<<"ans="<<dak[x][3]<<' '<<w3[ezx]<<' '<<w3[exy]<<' '<<me[x]<<endl;
	
	(ans += mod - (ll) (w2[exy] - 1) * (dak[y][1] - 2) % mod) %= mod;
	(ans += mod - (ll) (w2[ezx] - 1) * (dak[z][1] - 2) % mod) %= mod;
	(ans += mod - (ll) (dak[x][1] - 2) * (dak[x][1] - 2) % mod) %= mod;
//	cout<<"ans="<<ans<<endl; 
	
	(ans += mod - dak[y][2]) %= mod;
	(ans += mod - dak[z][2]) %= mod;
	
	(ans += w2[eyz] + w2[exy] + 2) %= mod;
	(ans += w2[ezx] + w2[eyz] + 2) %= mod;
	
//	cout << x << ' ' << y << ' ' << z << " : " << (ans + mod - preans) % mod << endl;
}

int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	L(i, 1, m) {
		int u, v;
		cin >> u >> v;
		++u, ++v;
		eu[i] = u;
		ev[i] = v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
		S[u].set(i * 2 - 1), S[u + n].set(i * 2);
		S[v].set(i * 2), S[v + n].set(i * 2 - 1);
	}
	L(i, 1, m) {
		int u = eu[i], v = ev[i];
		MP[getid(u, v)] = i;
		le[u] |= S[v], le[v] |= S[u];
		re[u] |= S[v + n], re[v] |= S[u + n];
	}
	
	L(i, 1, n) {
		me[i] = (le[i] & re[i]).count();
	}
	L(i, 1, m) {
		int u = eu[i], v = ev[i];
		w3[i] = (le[u] & re[v]).count();
//		cout << u << ' ' << v << " : " << w3[i] << endl;
		if(sz(G[u]) > sz(G[v])) swap(u, v);
		else if(sz(G[u]) == sz(G[v]) && u > v) swap(u, v);
		ve[u].push_back(v);
	}
	L(i, 1, n) {
		dak[i][0] = 1;
	}
	L(d, 1, 3) {
		L(u, 1, n) {
			for(auto v : G[u]) {
				(dak[v][d] += dak[u][d - 1]) %= mod;
			}
		}
	}
	
	L(i, 1, n) {
		for(int j : ve[i]) vis[j] = 1;
		for(int j : ve[i]) for(int k : ve[j]) if(vis[k]) {
			int ij = MP[getid(i, j)];
			int jk = MP[getid(j, k)];
			int ki = MP[getid(k, i)];
			w2[ij] += 1;
			w2[jk] += 1;
			w2[ki] += 1;
		}
		for(int j : ve[i]) vis[j] = 0;
	}
	
	L(i, 1, n) {
		for(int j : ve[i]) vis[j] = 1;
		for(int j : ve[i]) for(int k : ve[j]) if(vis[k]) {
			int ij = MP[getid(i, j)];
			int jk = MP[getid(j, k)];
			int ki = MP[getid(k, i)];
			
			cyc(i, j, k, ij, jk, ki);
			cyc(j, k, i, jk, ki, ij);
			cyc(k, i, j, ki, ij, jk);
		}
		for(int j : ve[i]) vis[j] = 0;
	}
	
	cout << ans << '\n';
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4448kb

input:

6 7
0 1
1 2
0 2
2 3
3 4
4 5
3 5

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 4400kb

input:

6 15
0 1
0 2
0 3
0 4
0 5
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

360

result:

ok 1 number(s): "360"

Test #3:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

2 0

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 3ms
memory: 4348kb

input:

2 1
0 1

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 1ms
memory: 4348kb

input:

2 1
0 1

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 4456kb

input:

2 1
0 1

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 2ms
memory: 4356kb

input:

2 0

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 2ms
memory: 4408kb

input:

2 1
0 1

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 2ms
memory: 4476kb

input:

3 3
1 2
0 2
0 1

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 2ms
memory: 4416kb

input:

3 2
0 1
0 2

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 2ms
memory: 4412kb

input:

3 2
0 2
0 1

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: 0
Accepted
time: 1ms
memory: 4424kb

input:

3 3
0 1
0 2
1 2

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 2ms
memory: 4376kb

input:

3 0

output:

0

result:

ok 1 number(s): "0"

Test #14:

score: 0
Accepted
time: 2ms
memory: 4488kb

input:

3 3
0 2
0 1
1 2

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: -100
Wrong Answer
time: 1ms
memory: 4388kb

input:

4 5
0 3
0 2
1 3
0 1
1 2

output:

998244345

result:

wrong answer 1st numbers differ - expected: '0', found: '998244345'