QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#959195 | #3768. 矩形并 | xianjing# | AC ✓ | 7ms | 3712kb | C++23 | 4.4kb | 2025-03-31 16:24:51 | 2025-03-31 16:24:59 |
Judging History
answer
//.................................................................................
//..................##..............##..................###....#####....####.......
//..................##..............##.................#####..##...##..#####.......
//..................##..............##................###.###.##...##..##..........
//......##..###..##.##.##...#####...##....####........##...##.##...##.##.###.......
//......##..###..##.######..######..##...######.......##...##..#####..#######......
//.......#..###..##.##..##......##..##..##...##.......##...##..#####..##...##......
//.......####.####..##..##..######..##..#######.####..##...##.##...##.##...##......
//.......####.####..##..##.##...##..##..##............###.###.##...##.##...##......
//........##..####..##..##.#######..##..######.........#####..##...##..#####.......
//........##...##...##..##..###.##..##...#####..........###....#####....###........
//.................................................................................
/**
* 2025-03-31 15:39:33
**/
//#pragma GCC optimize(1, 2, 3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define sort_all(x) sort(all(x))
#define sort1_all(x) sort(all1(x))
#define reverse_all(x) reverse(all(x))
#define reverse1_all(x) reverse(all1(x))
using i128 = __int128;
using ll=long long;
#define ldb long double
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ldb, ldb> pdd;
typedef pair<ll, int> pli;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<string, ll> psl;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<string, int> msi;
#define RED cout << "\033[91m"
#define GREEN cout << "\033[92m"
#define YELLOW cout << "\033[93m"
#define BLUE cout << "\033[94m"
#define MAGENTA cout << "\033[95m"
#define CYAN cout << "\033[96m"
#define RESET cout << "\033[0m"
// 红色
#define DEBUG1(x) \
RED; \
cout << #x << " : " << x << endl; \
RESET;
// 绿色
#define DEBUG2(x) \
GREEN; \
cout << #x << " : " << x << endl; \
RESET;
// 蓝色
#define DEBUG3(x) \
BLUE; \
cout << #x << " : " << x << endl; \
RESET;
// 品红
#define DEBUG4(x) \
MAGENTA; \
cout << #x << " : " << x << endl; \
RESET;
// 青色
#define DEBUG5(x) \
CYAN; \
cout << #x << " : " << x << endl; \
RESET;
// 黄色
#define DEBUG6(x) \
YELLOW; \
cout << #x << " : " << x << endl; \
RESET;
#define dddmin(x,y) (x=min(x,y))
#define dddmax(x,y) (x=max(x,y))
const int mod=1e9+7;
//const int mod=998244353;
random_device RD;
mt19937_64 rd(RD());
ll rn(int l, int r){
return l + rd() % (r - l + 1);
}
int qpow(int a,int b){
int base=1;
while(b){
if(b&1)base=base*a%mod;
b>>=1;
a=a*a%mod;
}
return base;
}
inline int lowbit(int x){
return x&-x;
}
inline int lt(int x){
return 1ll<<x;
}
void solve(){
//不可水群!!!!
//戒焦躁!!!!
//专注!!!
int a, b, x1, x2, y1, y2;
while(cin >> a >> b >> x1 >> x2 >> y1 >> y2){
int ans = a * b % mod * (y2 - y1) % mod * (x2 - x1) % mod;
ans = (ans + (a * (a + 1) % mod * b % mod * (b + 1) % mod * qpow(4, mod - 2) % mod) % mod) % mod;
int del[4]{};
int l1, l2, c1, c2;
l1 = x2 - x1;
c1 = y2 - y1;
l2 = max(0ll, a - x2);
c2 = max(0ll, b - y2);
int L = min(x2, a) - x1;
int R = min(y2, b) - y1;
L = max(L, 0ll);
R = max(R, 0ll);
del[0] = c2 * l2 % mod * l1 % mod * c1 % mod;
del[1] = l2 * R % mod * (R + 1) % mod * qpow(2, mod - 2) % mod * l1 % mod;
del[2] = c2 * L % mod * (L + 1) % mod * qpow(2, mod - 2) % mod * c1 % mod;
del[3] = L * R % mod * (L + 1) % mod * (R + 1) % mod * qpow(4, mod - 2) % mod;
del[0] += del[1] + del[2] + del[3];
del[0] = (mod - del[0] % mod) % mod;
ans = (ans + del[0]) % mod;
cout << ans << "\n";
}
return;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int ____=1;
// cin>>____;
while(____--)solve();
return 0;
}
//火车头长度 141
詳細信息
Test #1:
score: 100
Accepted
time: 7ms
memory: 3712kb
input:
1 1 2 3 2 3 10 10 1 5 1 5 1000000000 1000000000 1 1000000000 1 1000000000 1 2 2 5 1 4 2 5 1 5 2 4 1 4 3 4 1 5 2 3 1 4 2 4 5 3 1 4 1 2 5 2 3 5 4 5 3 2 3 5 1 4 5 3 4 5 1 3 5 5 1 5 2 5 4 4 1 5 2 5 1 2 1 5 3 5 3 4 3 4 1 2 2 2 1 4 1 3 3 1 1 4 1 4 2 4 1 5 2 5 4 2 2 3 3 5 1 3 1 2 1 2 2 4 1 3 1 5 5 2 2 3 2 ...
output:
2 3725 2793 21 120 26 53 117 65 54 117 465 274 19 72 32 33 123 46 9 88 65 36 252 83 159 17 330 261 186 84 26 45 34 75 34 65 30 88 107 12 105 38 46 15 85 29 55 78 55 96 17 39 60 20 17 56 45 5 18 96 30 25 108 146 114 65 19 192 51 17 42 54 132 110 75 42 75 66 150 7 7 173 33 95 75 294 45 247 25 35 110 2...
result:
ok 10000 lines