Общий форум#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? #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; } Использую метод отжига и у меня ТЛ 16 тест, в кф проверил что у меня на макс тесте работает не более 2с. Возник вопрос, админы специально поставили такое ограничение чтобы метод отжига не проходил ? #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <cmath> #include <deque> #include <queue> #include <algorithm> #include <iterator> #include <bitset> #include <iomanip> #include <functional> #include <list> #include <cctype> #include <array> #include <algorithm> using namespace std; int main() { int n; n = 5; vector<vector<int>> vec(n); for (int i = 0; i < n; ++i) { vec[i].resize(n); for (int j = 0; j < n; j++) { cin >> vec[i][j]; } } cout << min(min(min(vec[0][0] + vec[1][0] + vec[2][1] + vec[2][3] + vec[3][4], vec[0][0] + vec[3][0] + vec[2][3] + vec[1][2] + vec[1][4]), vec[0][0] + vec[0][2] + vec[1][2] + vec[1][3] + vec[3][4]), vec[0][0] + vec[0][2] + vec[2][3] + vec[1][3] + vec[1][4]) << endl; if (min(min(min(vec[0][0] + vec[1][0] + vec[2][1] + vec[2][3] + vec[3][4], vec[0][0] + vec[3][0] + vec[2][3] + vec[1][2] + vec[1][4]), vec[0][0] + vec[0][2] + vec[1][2] + vec[1][3] + vec[3][4]), vec[0][0] + vec[0][2] + vec[2][3] + vec[1][3] + vec[1][4]) == vec[0][0] + vec[1][0] + vec[2][1] + vec[2][3] + vec[3][4]) { cout << "1 2 3 4 5"; } else if(min(min(min(vec[0][0] + vec[1][0] + vec[2][1] + vec[2][3] + vec[3][4], vec[0][0] + vec[3][0] + vec[2][3] + vec[1][2] + vec[1][4]), vec[0][0] + vec[0][2] + vec[1][2] + vec[1][3] + vec[3][4]), vec[0][0] + vec[0][2] + vec[2][3] + vec[1][3] + vec[1][4]) == vec[0][0] + vec[3][0] + vec[2][3] + vec[1][2] + vec[1][4]) { cout << "1 4 3 2 5"; } else if (min(min(min(vec[0][0] + vec[1][0] + vec[2][1] + vec[2][3] + vec[3][4], vec[0][0] + vec[3][0] + vec[2][3] + vec[1][2] + vec[1][4]), vec[0][0] + vec[0][2] + vec[1][2] + vec[1][3] + vec[3][4]), vec[0][0] + vec[0][2] + vec[2][3] + vec[1][3] + vec[1][4]) == vec[0][0] + vec[0][2] + vec[1][2] + vec[1][3] + vec[3][4]) { cout << "1 3 2 4 5"; } else { cout << "1 3 4 2 5"; } cout << endl; } var n,k,ch,im:int64; begin read(n,k); n:=n-1; ch:=0; im:=1; while n>0 do begin if im<=k then begin n:=n-im; im:=im*2; ch:=ch+1; end; if im>k then begin n:=n-k; im:=im+k; ch:=ch+1; end; end; writeln(ch); end. well, i've also had WA 5, i tried to enter 4 2 and got 3 instead of 2. i found the mistake but then i got WA 14. i tried 6 4 and got 4 instead of 3 and understood that i had corrected the code wrong and only then i got AC. Edited by author 16.01.2020 21:20 Edited by author 16.01.2020 21:20 I hope these tests will be useful for you :) 4 5 0 3 4 1 2 3 1 2 4 and 7 7 0 1 2 1 3 2 4 2 5 3 6 3 7 4 7 The output must be 0 in both cases, but if you've done something wrong, it can be -1. Make sure your determination of connected components isn't wrong. you gave the wrong 1 test here's the correct 4 4 0 3 4 1 2 3 1 2 4 answer : 0 vector<vector<int64_t>> sequence = { {1,1,1,1,1,1,1,1,1,1,1,1}, {1,0,2,0,4,0,8,0,16,0,32,0}, {1,2,6,14,37,92,236,596,1517,3846,9770,24794}, // next is 62953 {1,0,14,0,154,0,1696,0,18684,0,205832,0}, // next is 2267544 }; The solution is a linear recurrence. Output is multiplied by 2. Edited by author 16.01.2020 16:32 I wrote a stupid solution and got wa32. Help please! In my case this test may help you 16 19 1 2 2 3 3 4 4 5 5 1 1 6 6 7 7 8 8 9 9 10 10 6 5 11 11 12 12 13 13 4 3 14 14 15 15 16 16 2 The sequence of contraction affects the solution if you do not repeat the process after release the blossom. if you contract (6,7,8,9,10), (4,5,11,12,13), (2,3,14,15,16) first you get maximum matching. but if you contract (1,2,3,4,5) first and don't repeat the process after release it you don't get to the maximum. Hope this helps. Thank you for this case! I didn't realize that the blossoms should be reset in each iteration. Edited by author 13.01.2020 19:23 Edited by author 13.01.2020 19:23 import java.util.*; public class LuckyNumber{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int x = in.nextInt(); int a1,a2,a3,b1,b2,b3; a1 = x/100000; a2 = (x/10000)%10; a3 = (x/1000)%10; b1 = (x/100)%10; b2 = (x/10)%10; b3 = x%10; if((a1+a2+a3) == (b1+b2+b3)) System.out.println("Lucky Number"); else if(a1+a2+a3-(b1+b2+b3)>1 ||(b1+b2+b3)-(a1+a2+a3)>1) { System.out.println("prostoi bilet"); } else System.out.println("Lucky Number budet sleduwii ili prediduwi bilet"); } } You should output "Yes" or "No" and nothing else Input: 2 2 1 2 2 1 2 My output: YES Answer: NO Rejudge pls! On #1 test my program output: 4 4 5 1 6 with code: cout<<4<<endl<<4<<" "<<5<<" "<<1<<" "<<6 but get wrong answer. Why? Because the first test is NOT the same as the sample What is 5 test ? TEST 10 1 7 1 1 8 1 1 2 1 7 10 1 7 9 1 9 3 1 8 4 1 2 5 1 5 6 1 6 + 10 + 1 + 2 + 8 + 3 + 6 ans = 8 if test 50000 300 300 My solution takes about 1.9 seconds (time library). the test fails. almost all the time spent on summarizing lists: "ncalls tottime percall cumtime percall filename:lineno(function)" "99402 1.773 0.000 1.773 0.000 {built-in method builtins.sum}" Maybe there is a way to more quickly summarize than the built-in function "sum"? Edited by author 12.12.2019 15:42 Edited by author 12.12.2019 15:42 Edited by author 12.12.2019 15:42 You may recalculate total sum of list on every iteration, if that lists changes predictable for you. For example, if you shift you list to the left for one position, and add some other value, then you may substract that shifted value and add new one, thus you perform updation. 5 6 0 6 5 0 There are no miracles in life 6 5 0 5 6 0 There are no miracles in life 3 6 2 6 5 1 There are no miracles in life 4 6 2 6 5 1 It is a kind of magic What is WA11? P.S. subfactorial func is correct P.P.S. Admins, is it possible there are some bugs here? Edited by author 29.02.2016 01:26 |
|