Common BoardThe delete operation is used at most once when finding a name! As I have encountered, I think the test is most likely several same length sequences which are not contained by any. Make sure you try this case before submitting :) Guys, Can somebody give me a hint to avoid Memory Limit (I use C#)? I've tried a lot of algorithms: 1. Composing full graph by using digits tree for all numbers. Processing graph by using Dijkstra and PriorityQueue (SortedArray<ShortestDistance, Queue<VertexIndex>>). 2. Creating tree of digits for all numbers. Processing graph "on the fly": obtaining all neighbor vertexes for current vertex (from previously created tree). The Dijkstra and the same PriorityQueue were used. 3. Using Dictionary<PhoneNumber, VertexIndex> for storing all numbers and vertexes. Processing graph "on the fly": obtaining all possible neighbors (135) and filter them by real vertexes from dictionary. The same PriorityQueue was used. 4. The same as 3, but instead of PriorityQueue, I've used Heap<ShortestDistance, VertexIndex>. After distance to some vertex was updated, I remove this vertex from Heap (if it exists there) and add it again, but with new key (distance). I even replaced usage of all pointers to objects by UShort indexes, and now I'm in stuck. I've started work on this task because accidentally send solution of other task here, but now I already hate test #8 :) Any ideas? Just for your interesting: my mistake was in composing result path - it was composed for each vertex O_o. Hope my previous post help somebody! solved :x Edited by author 26.03.2012 03:51 import java.util.Scanner; public class Bil { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a = input.nextInt(); int b = numbers (Math.abs(a)); if (a >= 0 )System.out.println(b); else {System.out.println(-b);} } public static int numbers( int a){ int sum = 0; if (a > 1){ for (int i = 2; i <= a; i++) sum +=i; } // else if (a == 0) sum = 0; else{ sum = 1; } return sum; } } // Nvidia CUDA Driver API 4.1 //======================== #include <cuda.h> #include <stdio.h> #include <device_launch_parameters.h> #include <Windows.h> //======================== #pragma comment(lib,"cuda.lib") //======================== int wmain() { // CUdevice cuDev; CUcontext cuCtx; CUmodule cuModl; CUfunction cuFunc; // CUdeviceptr pDmem[3]; CUstream stream[4]; CUevent start; CUevent end; size_t paramsize; void* kernelparams[4]; float time; // cuInit(0); cuDeviceGet(&cuDev,0); cuCtxCreate(&cuCtx,CU_CTX_SCHED_AUTO,cuDev); // cuEventCreate(&start,0); cuEventCreate(&end,0); // for(int i=0; i<4; i++) { if(cuStreamCreate(&stream[i],0)) { return 0; } } // cuModuleLoad(&cuModl,"matrixtile.ptx"); cuModuleGetFunction(&cuFunc,cuModl,"add"); // for(int i=0; i<3; i++) { if(cuMemAlloc(&pDmem[i],sizeof(int))) { return 0; } }
int a = 1; int b = 8; int r; cuEventRecord(start,0); if(cuMemcpyHtoDAsync(pDmem[0],(void*)&a,sizeof(int),stream[0])) { return 0; } if(cuMemcpyHtoDAsync(pDmem[1],(void*)&b,sizeof(int),stream[1])) { return 0; } if(cuMemcpyHtoDAsync(pDmem[2],(void*)&r,sizeof(int),stream[2])) { return 0; } // paramsize = sizeof(pDmem); kernelparams[0] = &pDmem[0]; kernelparams[1] = &pDmem[1]; kernelparams[2] = &pDmem[2]; kernelparams[3] = ¶msize;
// cuLaunchKernel(cuFunc,1,1,1,1,1,1,0,stream[3],kernelparams,0); cuEventRecord(end,0); cuEventSynchronize(end); cuEventElapsedTime(&time,start,end); wprintf(L"Time = %.7f\n\n",time); // cuMemcpyDtoHAsync(&r,pDmem[2],sizeof(int),stream[3]); cuCtxSynchronize(); // cuModuleUnload(cuModl); cuCtxDestroy(cuCtx); wprintf(L"result = %d\n",r); // ReadFile(GetStdHandle(STD_INPUT_HANDLE),0,0,0,0); return 0; } Time = 0.0076 milliseconds Edited by author 25.03.2012 21:23 you're genius bro ;) :D nice solution :) #include<iostream> #include<stdio.h> #include<string> using namespace std; int main() { int desk[][4] = { { 2, 3, 4, 4 }, { 3, 4, 6, 6 }, { 4, 6, 8, 8 }, { 4, 6, 8, 8 } }; int n; scanf("%d", &n); string str; getline(cin, str); char c, c1; int x, y; for (int i = 0; i < n; i++) { scanf("%c%c", &c, &c1); x = (c - 'a') > 3 ? 7 - (c - 'a') : (c - 'a'); y = (c1 - '1') > 3 ? 7 - (c1 - '1') : (c1 - '1'); printf("%d\n", desk[x][y]); getline(cin, str); } return 0; } Does the checking system enter only prime number ('p')? Should I do a check of input data? And What is the distinction of test 8? I broke my head, trying to solve the WA! Edited by author 25.03.2012 18:41 1) What does it mean by two-way road? Lets say I use road 1 and 3 in the sample.. To go from 1 to 3, it costs 300 and from 3 to 1 it is just 10. In that case we dont have route to go from 5 to 3. Then why is the answer correct? 1 3 5 2 1 to 3 -> 300 3 to 5 -> (No route, but taking 5 to 3 value) 300 + 20 5 to 2 -> (Again no route, taking 2 to 5 value) 300 + 20 + 15 2 to 1 -> (No route, using 1 to 2) 300 + 20 + 15 + 16 => 351 But consider 1 2 5 3 1 to 2 -> 16 2 to 5 -> 16 + 15 5 to 3 -> 16 + 15 + 20 3 to 1 -> 16 + 15 + 20 + 10 which is just 61 Could someone please explain why it is 1 3 5 2 and not 1 2 5 3? Both answers are correct. In first sample there are 2 two-way roads between crossings 1 and 3: one's length is 300 and the other's is 10. Of course, in optimal solution you will only use shortest road between some pair of crossings. This test is clearly incorrect: 4th line describes an edge connecting vertices 1 and 40. However, there are only vertices with numbers from 1 to 4. Most probably, 4th line should be "1 4 60". "2 3 4" is correct answer then. WA #39 Did somebody have the same problem? Edited by author 24.03.2012 14:17 Edited by author 24.03.2012 14:17 1.The relationship is always mutual,which means that if 1 has a friend 2,then 2 has a friend 1. 2.1 has a friend 2, and 2 has a friend 3 doesn't mean 1 and 3 are friends,thus be careful to use disjoint set. Hope they are helpful to you guys :) In C++ don't use cout and cin! Just use scanf(...) and printf(...). Enjoy! Edited by author 24.03.2012 00:22 http://tinyurl.com/825oh2g -> first link -> blablabla and test data. In test 8 output there is nothing close to "bargo". In test 7 the word is fargo, and it is present in corresponding input file. help. send please the test 1 for mail antonluzhbin@yandex.ru Does it contains only ['a'-'z'] and ['A'-'Z']? Yes. In the problem statement is written that they have deleted all punctuation marks. Edited by author 26.03.2012 14:03 Edited by author 26.03.2012 14:04 actually i dont have any idea for this my sir gave me this assessment i want to solve this problem please help me how to start the program and which concepts we want to use
When n = 0, if we have to calculate T, is the answer 'undefined' ? if we have to calculate V, is the answer 'error' or 'undefined'? Accepted. Formula should be understood like math :) Edited by author 19.03.2011 19:58 Edited by author 19.03.2011 19:58 I don't understend what to do in this case. If we have any of t,v,n,p given to us <= 0 then we should write 'error'? Or I haven't understood the problem right? I just haven't read properly. If we have input p = 0 and n = 0 then we should output 'undefined'. If (p = 0 and n <> 0) or (p <> 0 and n = 0) then we should output 'error'. When we calculate n and p CAN be 0. We just must output '0'. When we calculate T and V CAN'T be 0. We just must output 'error'. I hope it'll help and you will not be sitting for hours as I did. Sorry for my English, but I think it is possible to understand what I meant even with my mistakes. |
|