QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361044#6786. Let's Chatmatongc233AC ✓1ms3672kbC++202.1kb2024-03-22 18:28:192024-03-22 18:28:19

Judging History

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

  • [2024-03-22 18:28:19]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3672kb
  • [2024-03-22 18:28:19]
  • 提交

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<x;i++){
                for(int j=0;j<y;j++){
                    if(a[i].second>=b[j].first&&a[i].first<=b[j].second){
                        int st = max(a[i].first,b[j].first);
                        int ed = min(a[i].second,b[j].second);
                        if(ed-st+1>=m)
                        res += ed-m-st+2;
                    }
                }
            }
            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: 3672kb

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: 3664kb

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