QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#51665 | #4887. Fast Bridges | zhoukangyang# | WA | 3ms | 4824kb | C++11 | 2.0kb | 2022-10-03 12:36:48 | 2022-10-03 12:36:50 |
Judging History
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 ull unsigned 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
using namespace std;
const int N = 507, mod = 998244353, iv3 = (mod + 1) / 3;
int n, k;
struct tup {
int xl, xr, yl, yr;
} f[N];
int dis[N][N];
int arrx[N], arry[N], atotx, atoty;
bool vis[N];
int t[N];
int a[12][12][12][12];
int work(vector < pair < int, int > > vp) {
int ns = 0;
me(a, 0);
for(auto u : vp) {
int A = u.first, B = u.second;
L(h, 1, f[A].xl)
L(j, 1, f[A].yl)
L(k, 1, f[B].xr)
L(l, 1, f[B].yr)
ns += !a[h][j][k][l], a[h][j][k][l] = 1;
}
return ns;
}
vector < pair < int, int > > vq[N];
int solve(vector < tup > T) {
n = sz(T);
L(i, 1, sz(T)) f[i] = T[i - 1];
me(dis, 0x3f);
L(i, 1, n) dis[i][i] = 0;
L(i, 1, n) L(j, 1, n) if(f[i].xr <= f[j].xl && f[i].yr <= f[j].yl) dis[i][j] = 1;
L(k, 1, n) L(i, 1, n) L(j, 1, n) dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
L(i, 0, n) vq[i].clear();
L(i, 1, n) L(j, 1, n) if(dis[i][j] < n) vq[dis[i][j]].emplace_back(make_pair(i, j));
L(i, 1, n) f[i].xr = k - f[i].xr + 1, f[i].yr = k - f[i].yr + 1;
int qwq = 0;
L(i, 0, n - 1) if(sz(vq[i])) qwq += work(vq[i]), qwq %= mod;
return qwq;
}
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin >> n >> k;
if(n) assert(k <= 10);
vector < tup > A, B;
while(n--) {
tup a;
cin >> a.xl >> a.yl >> a.xr >> a.yr;
if(a.yl > a.yr) {
a.yl = k - a.yl + 1;
a.yr = k - a.yr + 1;
A.push_back(a);
} else {
B.push_back(a);
}
}
int ns = (ll) (k + 1) * k % mod * (k - 1) % mod * iv3 % mod * k % mod * k % mod;
(ns += mod - solve(A)) %= mod;
(ns += mod - solve(B)) %= mod;
cout << ns << '\n';
return 0;
}
/*
2 5
3 3 4 5
3 3 5 4
*/
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 4608kb
input:
2 2 1 1 2 2 1 2 2 1
output:
6
result:
ok answer is '6'
Test #2:
score: 0
Accepted
time: 2ms
memory: 4736kb
input:
0 1000000000
output:
916520226
result:
ok answer is '916520226'
Test #3:
score: 0
Accepted
time: 3ms
memory: 4824kb
input:
5 5 1 1 3 3 3 3 5 1 3 3 4 5 3 3 5 4 1 5 3 3
output:
946
result:
ok answer is '946'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 4664kb
input:
200 5 1 1 4 2 2 5 4 4 2 3 4 2 2 4 3 5 1 4 4 2 2 5 4 2 1 2 4 4 1 2 2 4 1 4 5 1 3 4 5 1 4 2 5 1 2 2 5 4 3 2 5 1 3 1 5 2 4 2 5 3 1 3 5 1 3 4 4 5 2 2 4 3 2 3 5 4 1 4 5 3 2 2 3 1 2 5 3 3 1 1 5 3 4 4 5 5 1 3 4 4 4 3 5 1 2 3 3 4 3 4 4 2 1 4 4 5 2 1 4 4 1 3 5 2 1 1 3 3 1 5 3 1 1 1 3 5 1 4 3 5 4 5 5 4 1 1 4 ...
output:
728
result:
wrong answer expected '708', found '728'