QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360979#6786. Let's Chatmatongc233WA 1ms3676kbC++142.1kb2024-03-22 17:13:072024-03-22 17:13:08

Judging History

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

  • [2024-03-22 17:13:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3676kb
  • [2024-03-22 17:13:07]
  • 提交

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 += ed-m-st+2;
                    }
                    else {
                        break;
                    }
                }
            }
            cout<<res<<'\n';

    }
    
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3676kb

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: -100
Wrong Answer
time: 1ms
memory: 3676kb

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:

0
1131992
5461412
0
385085
1579796
103122
0
791739
3661230

result:

wrong answer 1st lines differ - expected: '119342838', found: '0'