char buf[41]; unsigned hash() { unsigned h = 0; for (char* p = buf; *p; ++p) { h = h * 13 + *p; } return h & 511; } Edited by author 22.04.2019 21:30 1. I spent nearly a half of hour to clear that "a dangerous stuff" does not mean "student may be poisoned", but "he will be poisoned exactly because of the stuff". Why not use "a harmful stuff" everywhere? 2. And these words: "The food is cooked from M different food stuffs. There are N different food stuffs in the menu but not all of them are at the distribution...". Why not write "The distribution contains M different food stuffs from the menu. The menu consists of N different stuffs."? 3. So, I've understood that the distribution does not contains the stuffs from the first block. But it took much time because of bad description. Agree... simple problem, awful problem statement. I always get WA in #5 here is my code, somebody help me please. <code> #include<stack> #include<iostream> #include<algorithm> #include<vector> #include<list> #include<iterator> using namespace std; int getSafe(vector<string> a,int an, vector<string> b, int bn){ int d=0; for(int i=0;i<an;i++){ for(int j=0;j<bn;j++) if(a[i]==b[j]){ d++; break; } } return d; } struct ve{ vector<string> v; }; int main(){ int n,N,m; cin>>N; string str; vector<string> menu; for(int i=0;i<N;i++){ cin>>str; menu.push_back(str); } cin>>n; int a,b; cin>>b; vector<string> fMenu; for(int i=0;i<b;i++){ cin>>str; fMenu.push_back(str); } int i=0; int nums[102]; ve res[102]; while(i<n){ cin>>a; nums[i]=a; for(int j=0;j<a;j++){ //cout<<"d"; cin>>str; //cout<<"s"; res[i].v.push_back(str); } i++; } cin>>m; for(int i=0;i<n;i++){ int x=getSafe(res[i].v,nums[i],fMenu,n); int c=getSafe(menu,N,res[i].v,nums[i]); if(x-nums[i]==0) cout<<"YES\n"; else if(N-b-nums[i]+x-m<0) cout<<"NO\n"; else cout<<"MAYBE\n"; } return 0; } </code> I cannot understand the problem. The question is phrased pOorly ! If there is anyone, who can tell me, the question clearly, I am ready to phrase it in a better way. Use this statements: 1) There are N different food stuffs in the menu but not all of them are at the distribution. 2) The food is cooked from M different food stuffs. 3) The first student eats and he is not poisoned. 4) The first block describes the food stuffs dangerous for the first student, 5) the next K blocks — for the rest ones. And try to think a little. It's not very hard. ;) Combination formula can help. find #5 test, Please Maybe you have bug in calculating count of bad products among possible. I had WA #5 on this. I receive AV(CRASH) all the time. So, is there are someone who solve this problem on C? Best Regards, Veniamin. Judges, could you share to me this test N 16? Judjes, did you check this test? Edited by author 27.03.2005 22:52 Vladimir, Thanks for answer! Is it possible to get this test? If not, could you give me some hint of this case(which is used in test 16)? Veniamin. I’ve AC. And Test 16 consist of stings with spaces like Aaa bbb Cccccc ccvrfg cv c That was the point! The names can only contain letters and digits by statement. Please tell me, how I must use M from input??? And, by the way, why second person from sample input will poison? Assume the first man eats no products. In canteen you can find only M products, so if for us are bad only N - M products we have chance to live and if for us are bad N - M + 1 products (we know that one of them exactly is poisoned) we will die. Thanks for your hint, got AC... :) Does each student eat M products from canteen? if so, do we have after i-st student N-M*i products? And last student can't get 3 products. Otherwise, why second student don't take "Rafinat+Pastila+Chocolate" and stay alive? > Does each student eat M products from canteen ? yup > do we have after i-st student N-M*i products ? no, each student receive same products menu is fixed and it consist of M products from N given from the example first student test the food and he is OK, that means there are no stuffs in menu from his dangerous list { Rafinad, Kefir, Imbir } so here the menu consist of 3 stuffs from { Pastila, Smetana, Chokolade, Kljukva } the second student have 2 dangerous products from leaved and in any combination of menu he die :/ let products which eat first student will be in list A all other products in list B for each student we count products, which his take, which in list B if this counter = 0 then we write YES if this counter <= N - X - M, where X is count of products in list A then we write MAYBE else we write NO What is 'M'. Which of blocks belong to 'Yes','NO','Maybe' in output. Which of block belong to YES,NO,MAYBE. Edited by author 18.08.2007 13:58 Edited by author 18.08.2007 14:50 Edited by author 03.05.2007 22:12 Edited by author 03.05.2007 22:14 Edited by author 10.08.2007 02:54 Edited by author 10.08.2007 02:57 Edited by author 18.08.2007 14:51 IF you can,write me on serchch@mail.ru. Thank!!! Edited by author 03.05.2007 22:13 check your mail. Thank!!! Edited by author 10.08.2007 02:57 Edited by author 18.08.2007 14:51 Please,if you can,tell me how I must use m in this problem? Thank you very much!!! Edited by author 04.07.2007 22:27 Please,help! As far as I can remember this is simple problem for youngsters without any tricks,demands for speed and memory. Edited by author 11.07.2007 00:59 Edited by author 18.08.2007 14:48 No problem.I've AC now.(It was so stupid mistake) Edited by author 18.08.2007 14:48 I have Crach#15. And I know, that (n + 1) string in input is not number, because I catch Exception, than I convert this string to Integer. Thank you. I have AC now. When I'm sending my solve I'm getting WA on 16 test! Please help me with it. I think i know how to solve this problem, but I have another broblem. How to input the text without using "string" variable. If I use "char a[MaxN][MaxN]", how to identify each string?(C++)I don't want to use <string.h> because sometimes it doesn't work on this server. Thank's. I used std::string to solve this problem. But why do you afraid of using <string.h>? All standard functions of string.h are fully supported by the server. stricmp is not supported :( My prog gets TLE on test #17. The complexity of my prog is 100*100*log100, so it can't be that it really runs too slow. The only possibility is that it falls into an infinite loop when performing binary search for a food name, because the string inputted contains suffix spaces. Admins please correct this and rejudge the prob if this is true. Edited by author 10.01.2006 03:41 It can't be solved in 100*100*log100 because input may be as large as 100*100*40. Don't you read the whole input? It doesn't matter. 100*100*log100*40 is about 3e6, which is still not big enough to lead to TLE. You made a very tricky mistake. You compare string[40] and string 100*100*log100 times. This comparison works very slow because string[40] is casted to string every time. Thanks. You're right. When I changed 'string' into 'string[40]' I got AC very fast. This (subj) limitations is wrong... |
|