Anonymous
Can anyone explain this a bit for me :
cout<<34;
cout is responsible for converting 34 into an appropriate format and then delegate the job of communicating data to its internal module which is a stream buffer and we can use
cout.rdbbuf() to get a pointer to the internal module of stream buffer.
Sachin
Consider a tunnel on a one-way road. During a particular day, nn cars numbered from 11 to nn entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds.
A traffic enforcement camera is mounted at the tunnel entrance. Another traffic enforcement camera is mounted at the tunnel exit. Perfectly balanced.
Thanks to the cameras, the order in which the cars entered and exited the tunnel is known. No two cars entered or exited at the same time.
Traffic regulations prohibit overtaking inside the tunnel. If car ii overtakes any other car jj inside the tunnel, car ii must be fined. However, each car can be fined at most once.
Formally, let's say that car ii definitely overtook car jj if car ii entered the tunnel later than car jj and exited the tunnel earlier than car jj. Then, car ii must be fined if and only if it definitely overtook at least one other car.
Find the number of cars that must be fined.
Input
The first line contains a single integer nn (2≤n≤1052≤n≤105), denoting the number of cars.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤n1≤ai≤n), denoting the ids of cars in order of entering the tunnel. All aiai are pairwise distinct.
The third line contains nn integers b1,b2,…,bnb1,b2,…,bn (1≤bi≤n1≤bi≤n), denoting the ids of cars in order of exiting the tunnel. All bibi are pairwise distinct.
Output
Output the number of cars to be fined.
Examples
input
Copy
5 3 5 2 1 4 4 3 2 5 1
output
Copy
2
input
Copy
7 5 2 3 6 7 1 4 2 3 6 7 1 4 5
output
Copy
6
input
Copy
2 1 2 1 2
output
Copy
0
Note
The first example is depicted below:

Car 22 definitely overtook car 55, while car 44 definitely overtook cars 11, 22, 33 and 55. Cars 22 and 44 must be fined.
In the second example car 55 was definitely overtaken by all other cars.
In the third example no car must be fined.
professor
how can I avoid this E0513 a value of type "LPVOID" cannot be assigned to an entity of type "char *"?
#include <stdio.h>
#include <windows.h>
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996)
int main(int argc, char* argv[])
{
char* a, * b, * c;
HANDLE hHeap;
if (argc < 2) {
printf("Usage: heap argument\n");
exit(1);
}
hHeap = HeapCreate(HEAP_GENERATE_EXCEPTIONS, 5000, 9000);
a = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, 10);
b = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, 10);
c = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, 500);
strcpy(c, argv[1]); /* !overflow */
HeapFree(hHeap,0,c);
HeapFree(hHeap,0,b);
HeapFree(hHeap,0,a);
HeapDestroy(hHeap);
}
Jacobian
First I mapped the entry sequence i.e. if the order was 2 1 3 4 then I mapped 2 to 1, 1 to 2, 3 to 3 and 4 to 4. Then using this new mapping I calculated number of inversions in the exit sequence. Eg. the exit sequence was 3 2 1 4, so according to the new mapping it becomes 3 1 2 4. Now calculate inversions in this and get answer.
Anonymous
#include <stdio.h>
int main(int argc, char *argv[]){
int count;
for(count = argc - 1; count > 0;count--){
printf(" %s ", argv[count]);
}
printf("\n");
return 0;
}