|
|
Common BoardThank you very much! Finally I got AC. I've calculating the nim-sequence for this game about 3 hours)))) Thank you! Very useful articles. thank you sincerely!!!!!!!!!!!!!!!!! wonderful artical!!!!!!!!!!!!!! great ideas!!!!!!!!!!!!!!!!!!!!!!1 Edited by author 13.12.2011 17:50 I feel this is somewhat misleading as Data Structure isn't necessary for this problem. Agree. Solves with sort only. Sorting is good, yes. But it can be solved with data stuctures too. I used map<int,set<int> > and it gave slow AC (0.75 sec). Edited by author 11.12.2011 07:01 Edited by author 11.12.2011 07:02 please,somebody! take me tests!!! wa on 1st test :/ but work on all my tests GRBY YGBR equal BBGY GYBB equal YGBR GBRY different BYRG GYRB different mem[1][9] <=> 1=>>10 mem[20][9] <=> 20=>>299 or 29 ? I am Output Limit Exceed. my source is in C++. Here this is: #include<iostream.h> #include<string.h> main() { int len,temp,i; int n,m,j,p; char ch[12][12],word[15]; char letter; long int array[30]; for(i=0;i<27;i++) array[i]=0; cin>>n>>m>>p; for(i=1;i<=n;i++) cin>>ch[i]; for(i=1;i<=p;i++){ cin>>word; len=strlen(word); for(int k=0;k<len;k++){ temp=word[k]; array[temp-64]--; }} for(i=1;i<=n;i++) for(j=0;j<m;j++){ temp=ch[i][j]; array[temp-64]++; } for(i=1;i<27;i++){ temp=array[i]; letter=i+64; while(temp!=0){ cout<<letter; temp--; }} cout<<endl; return 0; } make temp!=0 - temp > 0; and some other changes, but it gets WA11 Edited by author 10.12.2011 12:10 Hi Admin, I got "Fail (compiler)" message if I use "goto" statement in Pascal... but it compiles fine on my machine.. Why? can I not use "goto" ? Thanks... the algorithm consist of transposition the most high soldier to the centre of the line and to the centre of the column. in cycle from 1 to n gives bubble sorting. Please can you explain how to do bubble sort in 2-d array here? I constructed such an algorithm. It requires the soldiers to be sorted by their height downwards. When the soldiers are sorted, take them one by one and fill the square diamond by diamond, starting from center. A "diamond" contains those cells (x,y) for which |x - x_center| + |y - y_center| == C, C ranges [0; n-1]. Edited by author 11.03.2009 08:54 There is a much simpler method, which also uses less memory. Hint: try a O(n) sort. Also try not to store n*n elements in memory (print line by line instead). if in a case p is abcde, is ab a prefix of p? or ab is prifix of cde? in other word is prefix and suffix of a word a part of that or placed in out of it? thank you. thanks. now i know what problem want. and i know when we say A is Prefix/suffix of B,=> B includes A. In my solution I read values like this: scanf("%d %d", &px[i], &py[i]); px[i] += 1000; py[i] += 1000; board[px[i]][py[i]] = 1; and get access violation on test #4; however, if I add right before accessing the array: if (px[i] < 0 || py [i] < 0 || px[i] > 2000 || py[i] > 2000) { while (1); } I get TLE on the same test. Are all the values of test #4 within the bounds -1000 <= x,y <= 1000 ?! Statement is fixed. Now -2000 <= x,y <= 2000 (as it was actually in tests). Thank you. Very nice problem!!! I solve it with vector. Min calculated just d*sin(acos(alpha)) :) Is there something special in test #23? I got crash (access violation). I have WA in this test. It's my code: #include <iostream> #include <string> #include <algorithm> #define N 1111 using namespace std; string s; int n,d1[N],d2[N],k; int main(){ getline(cin,s); n=s.length(); for (int i=0;i<n;i++){ for (k=1;i-k>=0 && i+k<n;k++) if (s[i-k]!=s[i+k]) break; d1[i]=max(k-1,-1); } for (int i=1;i<n;i++){ if (s[i]!=s[i-1]){ d2[i]=-1; continue; } for (k=1;i-k-1>=0 && i+k<n;k++) if (s[i-k-1]!=s[i+k]) break; d2[i]=max(k-1,0); } int *k1=max_element(d1,d1+n),*k2=max_element(d2+1,d2+n); if (*k1>=*k2+1) for (int i=k1-d1-*k1;i<=k1-d1+*k1;i++) cout<<s[i]; else for (int i=k2-d2-*k2-1;i<=k2-d2+*k2;i++) cout<<s[i]; return 0; } Can I get this test? a you must output a Locally my program prints a. But have AC only if I add if (n==1){ cout<<s<<endl; return 0; } I found my mistake, but I don't know, why there are different answers on my computer and here. Helpful test data: 6 6 1 2 8 2 3 3 3 5 2 2 4 7 4 6 2 2 5 6 Ans: Cost: 22 Cost: 25 Edited by moderator 12.11.2023 21:26 hi I am facing problem in converting. I try this: string lock1; int x; cin>>lock1; x= atoi(lock1.c_str()); it works but when I submit it it gives me compilation error, so any ideas or other way to convert from string to integer??? thank you. no thing wrong with my code the only thing missing that I did not include<cstring> and <string> and it's works now :) Which answer for test 2 2 #$ !* Who have AC program, please help. Well, what is your answer? By reading the text, I understand that the armies cannot attack the fortress alone. So I think the answer should be 2 (one for joining the armies, one for attacking the fortress). Of course, the answer is 2. First step for meeting the armies and the second one for attack. |
|
|