QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729862#9574. Stripsucup-team3160#WA 15ms5952kbC++142.3kb2024-11-09 17:57:442024-11-09 17:57:45

Judging History

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

  • [2024-11-09 17:57:45]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:5952kb
  • [2024-11-09 17:57:44]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, min, max) for(int i = (min); i <= (max); ++i)
#define nrep(i, max, min) for(int i = (max); i >= (min); --i)
#define reads(str) (scanf("%s", str + 1), strlen(str + 1))
#define case() int Ts = read(); rep(T, 1, Ts)
#define putf(flag) puts((flag) ? "Yes" : "No")
#define put(x) printf("%d ", x)
#define putl(x) printf("%lld ", x)
#define endl() putchar('\n')
using namespace std;

typedef long long ll;
inline int read()
{
    int now=0; bool nev=false; char c=getchar();
    while(c<'0' || c>'9') { if(c=='-') nev=true; c=getchar(); }
    while(c>='0' && c<='9') { now=(now<<1)+(now<<3)+(c&15); c=getchar(); }
    return nev?-now:now;
}

const int N = 1e6 + 10;

int a[N], b[N];
vector<pair<int, int>> vec;
vector<int> ans;

int main() {
    case() {
        int n = read(), m = read(), k = read(), w = read();
        vec = {}; ans = {};
        rep(i, 1, n) a[i] = read(), vec.push_back({a[i], 1});
        rep(i, 1, m) b[i] = read(), vec.push_back({b[i], 0});
        vec.push_back({w + 1, 0});
        vec.push_back( { 0 , 0 } ) ;
        int lastl = 0, lastr = w + 2, fl = 1, need = 0;
        sort(vec.begin(), vec.end());
        for ( auto t : vec )
        {
        	int x = t.first , op = t.second ;
        	assert( lastl <= lastr ) ;
//        	printf("now:%d %d\n" , x , op) ;
//        	printf("%d %d\n" , lastl , lastr) ;
            if(op == 0) {
                if(need) {
                    if(x <= lastl + k ) { fl = 0; break; }
                    ans.push_back(lastl + 1);
                    need = 0;
                }
                lastl = x; lastr = w + 2;
            } else {
                if(!need) {
                    need = 1;
                    lastr = x - 1;
                    lastl = max( x - k , lastl ) ;
                }
                else
                {
	                if ( x <= lastr + k ) 
					{
						lastl = max(x - k, lastl); 
						continue; 
					}
	                ans.push_back(lastl + 1);
	                lastl = lastl + k;
	                lastl = max(x - k, lastl);
	                lastr = x - 1;
	            }
            }
		}
//		puts("now:") ;
        if(!fl) { puts("-1"); continue; }
        put(ans.size()), endl();
        for(int i : ans) put(i); endl();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5952kb

input:

4
5 2 3 16
7 11 2 9 14
13 5
3 2 4 11
6 10 2
1 11
2 1 2 6
1 5
3
2 1 2 6
1 5
2

output:

4 
1 7 10 14 
-1
2 
1 4 
-1

result:

ok ok 4 cases (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 5872kb

input:

11000
3 8 2 53
32 3 33
35 19 38 20 1 30 10 6
7 10 1 42
3 14 4 36 28 40 22
17 20 12 41 27 7 1 19 13 9
6 6 13 78
55 76 53 32 54 58
62 45 21 4 7 61
8 7 3 68
9 26 54 31 22 3 38 65
34 16 58 47 52 29 53
5 8 4 33
33 5 30 6 15
27 12 9 28 19 2 13 10
6 1 2 48
8 12 48 1 41 31
40
7 6 7 61
20 19 30 52 49 17 40
3...

output:

2 
2 32 
7 
3 4 14 22 28 36 40 
3 
22 46 64 
8 
1 7 20 24 30 36 54 63 
3 
3 14 30 
6 
1 7 11 30 41 47 
4 
14 27 34 47 
2 
42 65 
1 
27 
1 
9 
1 
62 
5 
24 33 42 47 60 
2 
3 31 
3 
11 19 29 
3 
2 15 33 
3 
25 30 42 
3 
2 17 59 
4 
1 11 21 32 
2 
53 65 
3 
49 58 65 
3 
43 60 78 
1 
78 
4 
1 11 15 21 
...

result:

wrong answer Participant didn't find a solution but the jury found one. (test case 73)