답안 #1111445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111445 2024-11-12T08:32:32 Z StefanSebez Gift Exchange (JOI24_ho_t4) C++14
50 / 100
154 ms 10652 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
const int N=5e5+50,inf=1e9;
int a[N],b[N],c[2*N];
pair<int,int>Qs[200050];
int main(){
    int n;scanf("%i",&n);
    for(int i=1;i<=n;i++) scanf("%i",&a[i]);
    for(int i=1;i<=n;i++) scanf("%i",&b[i]),c[b[i]]=a[i];
    int q;scanf("%i",&q);
    for(int i=1,l,r;i<=q;i++){scanf("%i%i",&l,&r);Qs[i]={l,r};}
    bool subtask5=true;
    for(int i=2;i<=n;i++) if(a[i-1]>a[i]||b[i-1]>b[i]) subtask5=false;
    if(!subtask5){
		for(int I=1;I<=q;I++){
			int l=Qs[I].fi,r=Qs[I].se;
			vector<int>A,B;
			for(int i=l;i<=r;i++) A.pb(a[i]),B.pb(b[i]);
			B.pb(inf);
			sort(A.begin(),A.end()),sort(B.begin(),B.end());
			//for(auto i:A) printf("%i ",i);printf("\n");
			//for(auto i:B) printf("%i ",i);printf("\n");
			int m=A.size();
			bool res=true;
			for(int i=m-1,j=m-1;i>=0;i--){
				while(j>=0&&A[j]>B[i]) j--;j++;
				if(i<j||(i==j&&B[i+1]>c[B[i]])) res=false;
				//printf("%i: %i\n",i,j);
			}
			if(res) printf("Yes\n");
			else printf("No\n");
		}
    }
    else{
		int pref[n+10]={0};for(int i=2;i<=n;i++){pref[i]=pref[i-1];if(a[i-1]<b[i]) pref[i]++;}
		for(int I=1;I<=q;I++){
			int l=Qs[I].fi,r=Qs[I].se;
			if(pref[r]-pref[l]==0) printf("Yes\n");
			else printf("No\n");
		}
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:31:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   31 |     while(j>=0&&A[j]>B[i]) j--;j++;
      |     ^~~~~
Main.cpp:31:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   31 |     while(j>=0&&A[j]>B[i]) j--;j++;
      |                                ^
Main.cpp:12:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     int n;scanf("%i",&n);
      |           ~~~~~^~~~~~~~~
Main.cpp:13:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=1;i<=n;i++) scanf("%i",&a[i]);
      |                           ~~~~~^~~~~~~~~~~~
Main.cpp:14:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(int i=1;i<=n;i++) scanf("%i",&b[i]),c[b[i]]=a[i];
      |                           ~~~~~^~~~~~~~~~~~
Main.cpp:15:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     int q;scanf("%i",&q);
      |           ~~~~~^~~~~~~~~
Main.cpp:16:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for(int i=1,l,r;i<=q;i++){scanf("%i%i",&l,&r);Qs[i]={l,r};}
      |                               ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6528 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 2 ms 6648 KB Output is correct
13 Correct 2 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 1 ms 6480 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 2 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6528 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 2 ms 6648 KB Output is correct
13 Correct 2 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 1 ms 6480 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 2 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 2 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 2 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 2 ms 6480 KB Output is correct
27 Correct 1 ms 6480 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 2 ms 6480 KB Output is correct
30 Correct 2 ms 6480 KB Output is correct
31 Correct 2 ms 6480 KB Output is correct
32 Correct 2 ms 6480 KB Output is correct
33 Correct 1 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 34 ms 9640 KB Output is correct
5 Correct 35 ms 10180 KB Output is correct
6 Correct 32 ms 10404 KB Output is correct
7 Correct 30 ms 9420 KB Output is correct
8 Correct 33 ms 10188 KB Output is correct
9 Correct 34 ms 10260 KB Output is correct
10 Correct 31 ms 9420 KB Output is correct
11 Correct 37 ms 9676 KB Output is correct
12 Correct 32 ms 9420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6528 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 2 ms 6648 KB Output is correct
13 Correct 2 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 1 ms 6480 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 2 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 2 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 2 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 2 ms 6480 KB Output is correct
27 Correct 1 ms 6480 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 2 ms 6480 KB Output is correct
30 Correct 2 ms 6480 KB Output is correct
31 Correct 2 ms 6480 KB Output is correct
32 Correct 2 ms 6480 KB Output is correct
33 Correct 1 ms 6480 KB Output is correct
34 Correct 1 ms 6480 KB Output is correct
35 Correct 1 ms 6480 KB Output is correct
36 Correct 1 ms 6480 KB Output is correct
37 Correct 34 ms 9640 KB Output is correct
38 Correct 35 ms 10180 KB Output is correct
39 Correct 32 ms 10404 KB Output is correct
40 Correct 30 ms 9420 KB Output is correct
41 Correct 33 ms 10188 KB Output is correct
42 Correct 34 ms 10260 KB Output is correct
43 Correct 31 ms 9420 KB Output is correct
44 Correct 37 ms 9676 KB Output is correct
45 Correct 32 ms 9420 KB Output is correct
46 Correct 52 ms 7292 KB Output is correct
47 Correct 47 ms 9336 KB Output is correct
48 Correct 22 ms 7760 KB Output is correct
49 Correct 38 ms 9460 KB Output is correct
50 Correct 68 ms 9772 KB Output is correct
51 Correct 54 ms 9772 KB Output is correct
52 Correct 14 ms 7248 KB Output is correct
53 Correct 22 ms 8784 KB Output is correct
54 Correct 148 ms 9880 KB Output is correct
55 Correct 154 ms 10652 KB Output is correct
56 Correct 61 ms 9940 KB Output is correct
57 Correct 61 ms 8492 KB Output is correct
58 Correct 52 ms 10348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Incorrect 36 ms 9452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Incorrect 36 ms 9452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6528 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 2 ms 6648 KB Output is correct
13 Correct 2 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 1 ms 6480 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 2 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 2 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 2 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 2 ms 6480 KB Output is correct
27 Correct 1 ms 6480 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 2 ms 6480 KB Output is correct
30 Correct 2 ms 6480 KB Output is correct
31 Correct 2 ms 6480 KB Output is correct
32 Correct 2 ms 6480 KB Output is correct
33 Correct 1 ms 6480 KB Output is correct
34 Correct 1 ms 6480 KB Output is correct
35 Correct 1 ms 6480 KB Output is correct
36 Correct 1 ms 6480 KB Output is correct
37 Correct 34 ms 9640 KB Output is correct
38 Correct 35 ms 10180 KB Output is correct
39 Correct 32 ms 10404 KB Output is correct
40 Correct 30 ms 9420 KB Output is correct
41 Correct 33 ms 10188 KB Output is correct
42 Correct 34 ms 10260 KB Output is correct
43 Correct 31 ms 9420 KB Output is correct
44 Correct 37 ms 9676 KB Output is correct
45 Correct 32 ms 9420 KB Output is correct
46 Correct 52 ms 7292 KB Output is correct
47 Correct 47 ms 9336 KB Output is correct
48 Correct 22 ms 7760 KB Output is correct
49 Correct 38 ms 9460 KB Output is correct
50 Correct 68 ms 9772 KB Output is correct
51 Correct 54 ms 9772 KB Output is correct
52 Correct 14 ms 7248 KB Output is correct
53 Correct 22 ms 8784 KB Output is correct
54 Correct 148 ms 9880 KB Output is correct
55 Correct 154 ms 10652 KB Output is correct
56 Correct 61 ms 9940 KB Output is correct
57 Correct 61 ms 8492 KB Output is correct
58 Correct 52 ms 10348 KB Output is correct
59 Correct 1 ms 6480 KB Output is correct
60 Correct 1 ms 6480 KB Output is correct
61 Correct 1 ms 6480 KB Output is correct
62 Incorrect 36 ms 9452 KB Output isn't correct
63 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6528 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 2 ms 6648 KB Output is correct
13 Correct 2 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 1 ms 6480 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 2 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 2 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 2 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 2 ms 6480 KB Output is correct
27 Correct 1 ms 6480 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 2 ms 6480 KB Output is correct
30 Correct 2 ms 6480 KB Output is correct
31 Correct 2 ms 6480 KB Output is correct
32 Correct 2 ms 6480 KB Output is correct
33 Correct 1 ms 6480 KB Output is correct
34 Correct 1 ms 6480 KB Output is correct
35 Correct 1 ms 6480 KB Output is correct
36 Correct 1 ms 6480 KB Output is correct
37 Correct 34 ms 9640 KB Output is correct
38 Correct 35 ms 10180 KB Output is correct
39 Correct 32 ms 10404 KB Output is correct
40 Correct 30 ms 9420 KB Output is correct
41 Correct 33 ms 10188 KB Output is correct
42 Correct 34 ms 10260 KB Output is correct
43 Correct 31 ms 9420 KB Output is correct
44 Correct 37 ms 9676 KB Output is correct
45 Correct 32 ms 9420 KB Output is correct
46 Correct 52 ms 7292 KB Output is correct
47 Correct 47 ms 9336 KB Output is correct
48 Correct 22 ms 7760 KB Output is correct
49 Correct 38 ms 9460 KB Output is correct
50 Correct 68 ms 9772 KB Output is correct
51 Correct 54 ms 9772 KB Output is correct
52 Correct 14 ms 7248 KB Output is correct
53 Correct 22 ms 8784 KB Output is correct
54 Correct 148 ms 9880 KB Output is correct
55 Correct 154 ms 10652 KB Output is correct
56 Correct 61 ms 9940 KB Output is correct
57 Correct 61 ms 8492 KB Output is correct
58 Correct 52 ms 10348 KB Output is correct
59 Correct 1 ms 6480 KB Output is correct
60 Correct 1 ms 6480 KB Output is correct
61 Correct 1 ms 6480 KB Output is correct
62 Incorrect 36 ms 9452 KB Output isn't correct
63 Halted 0 ms 0 KB -