Common BoardMy two AC submissions give different answers on this test: 3 4 0 0 0 0 6 1 5 5 2 8 5 3 P.S. The first test case isn't the sample. Edited by author 19.11.2013 01:26 My AC solution outputs "NO" on that test case. I WAed many many times, and finally got AC. Test6 is 0, whose answer is 2. Test 7 is probably 1 or 2, which my previous program had given incorrect answer to. The answer to Test 8 has to be 36, because I used "for(i=x;i<36;i++)" and wa8. (I also saw some prog posted on this forum had the same problem) When I found this and changed into "<=", AC at last. Sorry for my poor English. Hope these can help you guys somehow. Good luck! Thank to your help. Sorry for my poor English,too. Thank you, your hints helped me to get AC. I got Crash (integer division by zero) before. unfortunately, it didn't help me :( still get WA8, any ideas?? I WAed many many times, and finally got AC. Test6 is 0, whose answer is 2. Test 7 is probably 1 or 2, which my previous program had given incorrect answer to. The answer to Test 8 has to be 36, because I used "for(i=x;i<36;i++)" and wa8. (I also saw some prog posted on this forum had the same problem) When I found this and changed into "<=", AC at last. Sorry for my poor English. Hope these can help you guys somehow. Good luck! Thanks... Thanks, my program went in cycle to 35 instead of 36) Hi, why is a problem author talking about bubble sort? And why a lot using stl stable_sort? Where is a differents of stl sort? In this test N=50 and the answer is 1069. I spent about an hour till i figured out that: If it is impossible to get from the computer to the refrigerator, you should output 0 0. !!!! Thank u so much! How should I forget this! i really don't understand why i got WA #1...i try a lot of tests and i always have the right answer, could anyone give me test 1, please, thx~ Edited by author 26.04.2012 11:47 Edited by author 26.04.2012 11:48 #include<bits/stdc++.h> using namespace std; int main(){ long long a[10],l,s,z=1,q,f; vector<long long>v; vector<long long>p; bool prime[10000]; memset(prime,true,sizeof(prime)); for(int i=2;i<=10000;i++){ if(prime[i]){ for(int j=i*2;j<=10000;j=j+i){ prime[j]=false; } } } for(int i=2;i<=10000;i++){ if(prime[i]){ v.push_back(i); } } q=v.size(); f=v[q-1]; for(int i=2;i<=f;i++){ p.push_back(0); } for(int j=0;j<10;j++){ cin>>a[j]; } for(int i=0;i<10;i++){ l=0,s=0; while(a[i]>=v[l]){ if(a[i]%v[l]==0){ //cout<<a[i]<<" "<<v[l]<<endl; p[v[l]]++; a[i]=a[i]/v[l]; } else{ l++; } } } for(int i=0;i<=p.size();i++){ z=(z*(p[i]+1))%10000; } z=z%10; cout<<z; return 0; } If you have WA #9 try this: 4 1 1 32300 0 * 1 1 32300 0 * 1 1 32300 0 * 1 1 32300 0 answer: 129200 a=int(raw_input()) count=2 for i in range(0,a): b=str(raw_input()) if b[-4]=='+': count+=2 else: count+=1 if count==13: count+=1 print(count*100) solved! Since the problem says names consist of Latin letters (donno if + is used in Latin names), so string matching must include '+one' rather '+' so after correction of if b[-4]=='+': to if b[-4:]=='+one': it got accepted I really appreciate your help guys, please give a test, I spend so much time to solve this problem, now I don't wanna leave it like that. Now I have WA23, any ideas? Если вы отсекли тарелки (мысленно), они все равно не могут быть ближе чем им позволяют их настоящие радиусы Thank you very much. You helped me a lot. 1)Pls, give me some tests 2)Am I right that answer < 10^18? Edited by author 22.07.2019 23:42 def bin_Search(arr, val): low = 0 high = len(arr)-1 while low <= high: mid = (low + high) // 2 if val < arr[mid]: high = mid - 1 elif val > arr[mid]: low = mid + 1 else: return True else: return False first = ["Alice", "Ariel", "Aurora", "Phil", "Peter", "Olaf", "Phoebus", "Ralph", "Robin"] first.sort() second = ["Bambi", "Belle", "Bolt", "Mulan", "Mowgli", "Mickey", "Silver", "Simba", "Stitch"] second.sort() third = ["Dumbo", "Genit", "Jiminy", "Kuzko", "Kida", "Kenai", "Tarzan", "Tiana", "Winnie"] third.sort() n = int(input()) pos = 1 steps = 0 for i in range(n): name = str(input()) if bin_Search(first, name) == True: steps += pos - 1 pos = 1 elif bin_Search(second, name) == True: if (pos - 2) < 0: steps += ((pos - 2) * -1) pos = 2 else: steps += pos - 2 pos = 2 else: if (pos - 3) < 0: steps += ((pos - 3) * -1) pos = 3 else: steps += pos - 3 pos = 3 print(steps)
In this solution i used binary search m, n = map(int, input().split()) if (m*n) % 2 == 0: print("[:=[first]") else: print("[second]=:]") import sys from math import sqrt potok = sys.stdin.read() spisok = potok.split()[::-1] if sys.getsizeof(potok)>262144: print('большой объем') quit() for i in spisok: i=int(i) if i>10**18 or i<0: print('неверный диапозон') quit() res = sqrt(int(i)) print("%.4f" % res) del Edited by author 21.07.2019 11:08 Input 3 3 1 1 1 3 3 Output 0 is it correct? I think so. My AC solution outputs 0. It should be noted that the problem statement doesn't mention what happens if you can't get next to the demon in at most L moves. Either such a test is invalid or you should output 0, since you can't stike it, thus you give it a stike of at most 0 intensity. #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { int co1=0,co2=0,co3=0,c=0; //init //1 cin >> co1; int *nm1 = new int[co1]; for (int i = 0; i < co1; i++) { cin >> nm1[i]; } //2 cin >> co2; int *nm2 = new int[co2]; for (int i = 0; i < co2; i++) { cin >> nm2[i]; } //3 cin >> co3; int *nm3 = new int[co3]; for (int i = 0; i < co3; i++) { cin >> nm3[i]; } for(int i=0;i<co1;i++) { for(int k=0;k<co2;k++) { if(nm1[i]==nm2[k]) { for(int j=0;j<co3;j++) { if(nm2[k]==nm3[j]) { c++; break; } } break; } } } cout << c; system("pause"); return 0; } f = int(input()) friends = [] cnt = 0 for i in range(f): j = str(input()) if j[-4:] == "+one": cnt += 200 else: cnt+= 100 if ((cnt/100)+2) == 13: cnt += 300 else: cnt += 200 print(cnt) I solve it by this def bin_Search(arr, val): low = 0 high = len(arr)-1 while low <= high: mid = (low + high) // 2 if val < arr[mid]: high = mid - 1 elif val > arr[mid]: low = mid + 1 else: return True else: return False aa = int(input()) aArr = list(map(int, input().split())) b = int(input()) bArr = list(map(int, input().split())) c = int(input()) cArr = list(map(int, input().split())) aArr.sort() bArr.sort() cArr.sort() cnt = 0 for i in aArr: s = bin_Search(bArr, i) if s == True: s1 = bin_Search(cArr, i) if s1 == True: cnt += 1 print(cnt) Here i use binary search After going through all the discussion topics, I found that this problem can be solved using different techniques. I have made a list of keywords, and I would like to know exactly how many different ways are there to solve this problem? 1) Brute force 2) Bit mask 3) Dynamic Programming 4) Backtracking 5) Balanced Partition 6) Partition problem 7) Greedy algorithm If you can solve the question with DP, you should avoid Brute Force. Although, I could not come up with a Greedy algorithm. I solved it using DP. My idea: 1) if triangle is right, answer is obvious) 2) if triangle is equilateral, there is no solution 3) in other cases try to split the triangle into 2 right triangles to get coordinates Correct me if I'm wrong or give test which fail that algo. 17,65,80 result: 0 0 33 -56 48 -64 Edited by author 18.07.2019 20:22 Edited by author 18.07.2019 20:25 Edited by author 18.07.2019 20:26 |
|