QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361001 | #6786. Let's Chat | matongc233 | AC ✓ | 1ms | 3624kb | C++20 | 2.1kb | 2024-03-22 17:39:59 | 2024-03-22 17:40:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 110, MOD = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef queue<PII> QPII;
typedef stack<int> SI;
typedef vector<PII> VPII;
typedef deque<int> DPII;
typedef queue<int> QI;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, m, x, y;
PII a[N], b[N], c[N], d[N];
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while(t--){
cin >> n >> m >> x >> y;
for (int i = 0; i < x; i++)
{
cin >> a[i].first >> a[i].second;
}
for (int i = 0; i < y; i++)
{
cin >> b[i].first >> b[i].second;
}
sort(a, a + x);
sort(b, b + y);
int idxc=0,idxd=0;
c[idxc++]=a[0];
d[idxd++]=b[0];
for (int i = 1; i < x; i++){
if(c[idxc-1].second>=a[i].first){
c[idxc-1].second = max(c[idxc-1].second,a[i].second);
}
else {
c[idxc++] = a[i];
}
}
for (int i = 1; i < y; i++){
if(d[idxd-1].second>=b[i].first){
d[idxd-1].second = max(d[idxd-1].second,b[i].second);
}
else {
d[idxd++] = b[i];
}
}
ll res =0;
for(int i=0;i<idxc;i++){
for(int j=0;j<idxd;j++){
if(c[i].second>=d[j].first&&c[i].first<=d[j].second){
int st = max(c[i].first,d[j].first);
int ed = min(c[i].second,d[j].second);
// if(ed-st+1>=m)
res += max(0,ed-m-st+2);
}
// else {
// break;
// }
}
}
cout<<res<<'\n';
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
2 10 3 3 2 1 3 5 8 10 10 1 8 10 10 5 3 1 1 1 2 4 5
output:
3 0
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
10 978378582 3619603 47 74 479986 5351489 5420308 7962369 11344514 15240567 28052230 34309090 69930493 71370103 96064381 113030999 131487830 167306026 201120250 210905551 215581108 218116928 239370726 250969994 251488779 259451325 264979602 268998475 277209414 278821999 294684099 297838279 300870315...
output:
119342838 35153801 144883974 82675908 33074404 41458373 4138220 69656059 71436009 110675349
result:
ok 10 lines