Common BoardTest case #6: 9 40 10 10 10 10 10 10 10 10 10 10 0 5 6 1 0 0 0 0 0 0 12 20 Answer: 158882255 Test case #12: 10 20 52 4 2 3 6 7 6 3 6 5 6 6 0 0 0 0 1 0 0 0 0 1 10 50 Answer: 978217740 PyCharm calculates n=2000 in 0.55 sec while here I got exceed time limit with 2.020 sec. I don't get it. Can't find the error, because it gives the same answers as those stupid precalc solutions: #include <bits/stdc++.h> using namespace std; using ll = long long; int soma[40] = {0}; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, i, lim; ll ans = 0; cin >> n; lim = pow(10, n/2); for(i=0; i<lim; ++i){ soma[i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10]++; } for(i=0; i<=n*9; ++i){ ans += soma[i]*soma[i]; } cout << ans << '\n'; return 0; } for(i=0; i<=n*9; ++i){ ans += soma[i]*soma[i]; } i is out of soma range. #include<bits/stdc++.h> using namespace std; int n,m,q,a[100003],b[100003],c[100003]; vector<pair<int,int> >v; vector<int>g[100003]; bool vis[100003]; int qq[100003]; map<int,int>mp; void dfs(int x,int cc){ vis[x]=1; for(int i=0;i<g[x].size();i++) if(!vis[g[x][i]]) dfs(g[x][i],cc); qq[x]=cc; } int main(){ cin>>n>>m; for(int i=0;i<m;i++) cin>>a[i]>>b[i], a[i]--, b[i]--; cin>>q; for(int i=0;i<q;i++)cin>>c[i],c[i]--,v.push_back(make_pair(a[c[i]],b[c[i]])),a[c[i]]=b[c[i]]=-1; reverse(c,c+n);reverse(v.begin(),v.end()); for(int i=0;i<m;i++) if(a[i]!=-1) g[a[i]].push_back(b[i]), g[b[i]].push_back(a[i]); int cnt=0; for(int i=0;i<n;i++) if(!vis[i]) mp[cnt]=cnt, dfs(i,cnt++); vector<int>ans; for(int i=0;i<q;i++){ ans.push_back(cnt); if(mp[qq[v[i].first]]!=mp[qq[v[i].second]]) mp[qq[v[i].first]]=mp[qq[v[i].second]], qq[v[i].first]=qq[v[i].second], cnt--; } reverse(ans.begin(),ans.end()); for(int i=0;i<ans.size();i++) cout<<ans[i]<<' '; } are there any test? 5 8 2 3 1 2 2 5 1 4 1 5 3 4 3 4 4 4 8 7 6 8 2 3 4 5 1 JavaEntryPointWrapper.java:10: error: cannot access Oppa Oppa.main(args); ^ bad source file: .\Oppa.java file does not contain class Oppa Please remove or make sure it appears in the correct subdirectory of the sourcepath. 1 error Выходит такая ошибка, почему? У меня аналогичная ошибка. В том, что файл содержит один публичный класс, совпадающий с именем файла уверен на 100%. Причем проверил на файлах, которые отправлял ранее и удачно решенные, тоже самое. Даже решение из руководства не проходит... Please give this test! lifanov@mail.ru Oh, I has mixed too, but now it works, thank you :) Please, delete my account. I don't need it anymore. Please, delete my account. I don't need it anymore. but I couldn't find any way to delete the post Edited by author 27.01.2020 01:24 Edited by author 27.01.2020 01:24 Edited by author 27.01.2020 01:24 I've passed all the tests the forum had. Can someone give me more Try the following 2 tests: 2 0 10000 2 20000 10000 and 2 0 10000 2 0 -10000 What answer is issued by your program? Edited by author 14.02.2013 20:37 YES, YES and look like its right? Very easy:) *first if k>n/2 make it smaller n/2: k=n-k+1 *then the answer is (n-k-2)
(......[Vasya].......[n-1][n] if [n-1] and [n] sit,then all people between [Vasya] and [n-1] will stumble at Vasya. And this will be the maximal answer ) *special case: n=2 => answer is 0 i dnt understand ur soln. why it be so?? the prog sttmnt says visitor chooses left || right end based on minimal no. of people s/he need to stumble upon. so let be test: 10 3 ur soln gives: 5 let last 2 and 1st 2 beseated. now why rest people should choose left end. prog sttmnt says it shd be right end. because only 2 need to be stumbled upon if right else 3. bt ur soln gives ac. so i thnk the prog sttmnt is all wrong || i am weak in english || the author is!!! Edited by author 29.11.2009 17:00 Roland is right example: 6 (1 Man, 2 Man, 3 empty, 4 empty, 5 empty, 6 You); answer - 3 Can you explain how do you get answer 3 for test 6,1? My solution: Veeeee Veeee1 V2eee1 V2ee31 V24e31 V24531, Where V - Vasya, e - empty place, 1,2,3... - visitors. Numbers 2 and 4 will stumble Vasyas feet, so my answer is 2. Veeeee Veeee1 Veee21 Vee321 Ve4321 V54321 The worst case. Answer - 3. Why 3? i think it have to be 4. Like Veeee1 - 0, Veee21 - 1, Vee321 - 2, Ve4321 - 3, V54321 - 4. The first case has the same problem tho Nvm, i get it. (the last sentence in first paragraph) Edited by author 23.01.2020 16:05 I think is 2 (1 man, 2 man ,3 empty, 4 man,5 man, 6 you) ,the 3man may from left Edited by author 11.09.2016 19:43 Edited by author 11.09.2016 19:43 I don`t understand why it works. Example: 10 4 ###[Vasya]###### At worst viewers with the numbers 1, 2 will come first: [1][2]#[Vasya]###### and viewer 3 stumbles over Vasya`s feets. Next come viewers with the numbers 9 and 10: [1][2][3][Vasya]####[9][10] and viewers 5, 6, 7, 8 stumble over feets. So the answer is 5, but your program (AC program!) gives 4... Edited by author 08.12.2010 14:45 Next come viewers with the numbers 9 and 10: [1][2][3][Vasya]####[9][10] and viewers 5, 6, 7, 8 stumble over feets. You should consider only those viewers who stumble Vasya's feet. Write order for this test. ###[Vasya]###### ###[Vasya]#####[1] ###[Vasya]####[2][1] ###[Vasya]###[3!][2][1] ###[Vasya]##[4!][3!][2][1] ###[Vasya]#[5!][4!][3!][2][1] ###[Vasya][6!][5!][4!][3!][2][1] Edited by author 14.12.2010 09:37 Edited by author 30.08.2011 05:38 Hello My solution failed on test 21. Passed next cases: 5 5 2 2 2 3 4 0 0 5 4 4 1 4 1 2 3 2 5 4 2 2 1 1 1 5 2 5 7 4 1 4 1 2 3 1 10 18 2 2 2 2 2 2 2 2 2 2 0 0 If you have any idea please let me know. Thank you Edited by author 21.08.2015 10:49 7 4 4 1 4 1 2 6 7 Ans 3 2 5 8 2 2 2 1 2 5 2 Edited by author 24.08.2019 14:48 I passed all those tests, but have WA2 :D #include <iostream> using namespace std; int main() { int n, k; int i; int show, type; int showTotal = 0, typeTotal = 0; int neededType; cin >> n >> k; for ( i = 1; i <= n; i++) { cin >> show >> type; if (show - type == 2) showTotal = typeTotal = 0; else { showTotal += show; typeTotal += type + 2; } } neededType = k + showTotal - typeTotal - 2; if (neededType > 0 && neededType < 101) cout << neededType << endl; else { cout << "Big Bang!" << endl; } return 0; } maybe problem in this neededType > 0 || neededType < 101 UPD: result must be only bigger than zero! i have AC) Edited by author 21.01.2020 23:21 #include <iostream> using namespace std; int main() { int n,a[100],b[100],c,d,i,j; cin>>n; for(i=0;i<n;i++) cin>>a[i]>>b[i]; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(b[i]<b[j]) { c=b[i]; b[i]=b[j]; b[j]=c; d=a[i]; a[i]=a[j]; a[j]=d; } for(i=0;i<n;i++) cout<<a[i]<<' '<<b[i]<<'\n'; return 0; } Help me! I'm die. Sorrry,my English is poor. I will try my best to understand you. Sort declared in the task is stable. Your sort isn't stable Let we have scores: ("team1", 10), ("team2", 10), ("team3", 15). Your code when i=0, j=2 swaps team1, team3: ("team3", 15). ("team2", 10), ("team1", 10). Note: when you fix your sort you'll face the fact real bubble sort is too slow. Try this simple test: 11123 Answer: 111 Please help with wrong answer 7. Possible input? my solution is the following: start with least common multiple = 1 make char array of 1000 000 to track forbidden divisors let div be the divisor and ans the answer if ans == 1 make new lcm of the previous lcm and current divisor. if it is over 10^12 - fail. find all the divisors of div, check that they are not forbidden in the forbidden array if ans == 0 - check if lcm is divisible by the divisor and fail if it is.
complexitiy O(n * sqrt(1000000)) (sqrt from the "find all divisors) my solution gets 0.5 sec (using cin,cout with tie(null)) what is the solution that gets less than 0.1 sec? Is there any hint? #include<stdio.h> #include<math.h> int main() { unsigned long long int a[1000],i=0,b,c; double s; while(scanf("%llu",&b)!=EOF) { a[i]=b; i++; c=i; } for(i=c;i>=0;i--) { s=sqrt(a[i]); printf("%.4lf\n",s); } return 0; } |
|