| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 13068 | Dynamic Programming |
|
| 13069 | Magic Cell Moving |
|
| 13070 | Guuguuloo |
|
Description
This is a partial judge problem OwO
You are given N integers. You need to sort them in decreasing order.
Partial Code
main.c
#include<stdio.h> #include<stdlib.h> #include "function.h" #define maxn 100005 int arr[maxn]; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&arr[i]); qsort(arr+1, n, sizeof(int),cmp); for(int i=1;i<=n;i++) { if(i != 1) printf(" "); printf("%d",arr[i]); } printf("\n"); return 0; }
function.h
int cmp(const void*, const void*);
You need to implement the cmp function which is the fourth parameter of the qsort function in main function.
Input
The first line contains one integer N (1 ≤ N ≤ 105) – the number of integers you are given.
The second line contains N integers a1, a2, ..., aN (1 ≤ ai ≤ 105).
Output
Ouput the given N integers in decreasing order.
Sample Input Download
Sample Output Download
Partial Judge Code
13068.cPartial Judge Header
13068.hTags
Discuss
Description
UPD(2020/12/25 22:40): We update the description to make the problem clearer("puzzle floor mat" has been replaced by "magic cell"). Sorry for the inconvenience.
You stand on a magic cell in the beginning. And there must be exactly one interger on every magic cell and exactly four portals on its top-side, right-side, bottom-side and left-side, respectively. The integer on the magic cell where you stand in the beginning is 0 and there is a DP(dynamic portal) on the magic cell where you stand in the beginning.
Now you need to do Q operations. There are 6 kinds of operations:
- Create a new magic cell. And some portal A on the magic cell where you stand will connect to the corresponding portal B on new magic cell(top-side is corresponding to bottom-side and vice versa; left-side is corresponding to right-side and vice versa). B will also connect to A.
- Go into some portal C on the magic cell where you stand(i.e move to the magic cell whose some portal is connected to portal C which is on the magic cell where you stand).
- Change the integer on the magic cell where you stand.
- Output the integer on the magic cell where you stand.
- Create a new DP on the magic cell where you stand. And remove the previous DP(so there must be exactly one DP at the same time).
- Move to the magic cell where DP is.
It's guaranteed that:
- For every time you do operation 1, portal A must not connect to any portal.
- For every time you do operation 2, portal C must connect to some portal.
Input
The first line contains one integer Q (1 ≤ Q ≤ 105) – the number of operations you need to do.
Then Q lines follow. The i+1-th line first contains one integers typei (1 ≤ typei ≤ 6) – the type of operations you need to execute. If the operation is one of the first three operations, then there are still some integers you need to read:
- typei = 1: two integers dir, val (0 ≤ dir ≤ 3, 0 ≤ val ≤ 109) follow – which portal will connect to some portal on new magic cell(0 for top-side; 1 for right-side; 2 for bottom-side; 3 for left-side) and the interger on new magic cell.
- typei = 2: one integer dir (0 ≤ dir ≤ 3) follows – which portal you need to go into.
- typei = 3: one integer val (0 ≤ val ≤ 109) follows – the new value for the integer on the magic cell where you stand.
Output
For every fourth operations output the integer on the magic cell where you stand then.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
You are given N different integers a1, a2, ..., aN.
You need to execute Q operations. There are two kinds of operations:
1. Remove xi from a1, a2, ..., aN if xi is in a.
2. Output "Yes" if yi is in a1, a2, ..., aN, otherwise output "No".
Note: be careful of the efficiency of your strategy. And we suggest you to solve this problem by not using binary search.
Input
The first line contains one integer N (1 ≤ N ≤ 105) – the number of integers you are given.
The second line contains N integers a1, a2, ..., aN (1 ≤ ai ≤ 109).
The third line contains one integer Q (1 ≤ Q ≤ 105) – the number of operations you need to execute.
Then Q lines follow. The i+3-th line contains one integer typei (1 ≤ typei ≤ 2) – the type of operations you need to execute. If typei = 1 then one integer xi (1 ≤ xi ≤ 109) follows, otherwise one integer yi (1 ≤ yi ≤ 109) follows.
It's guaranteed that:
- Every xi must be greater than or equal to the previous xi.
- Every yi must be greater than or equal to the previous yi.
- For the first seven testcases: 1 ≤ N ≤ 1000
Output
For every second operations output whether yi is in a1, a2, ..., aN or not then.