Common BoardWhy do they want me to do? How to understand "equal-sized parts"? Same amount of dots on both sides Edited by author 21.07.2020 14:25 are leading zeroes allowed? for example... will 0110 be counted as a valid 4 digit lucky number? #include<bits/stdc++.h> using namespace std; //input section #define si1(x) scanf("%d",&x) //one integer #define si2(x,y) scanf("%d%d",&x,&y) //two integers #define si3(x,y,z) scanf("%d%d%d",&x,&y,&z) //three integers #define sl(x) scanf("%lld",&x) //long long int #define sul(x) scanf("%llu",&x) //unsigned long long #define ss(x) scanf("%s",s) //string #define sd(x) scanf("%lf",&x) //double //output section #define pf printf #define pfi(x) printf("%d\n",x) #define pfl(x) printf("%lld\n",x) #define pfd(x) printf("%lf\n",x) #define nl printf("\n") //data type #define ll long long int #define ld long double #define ull unsigned long long //general #define pb push_back #define mp make_pair #define f first #define s second #define all(x) x.begin( ),x.end( ) #define sv(x) memset(x, 0, sizeof(x)) #define PI 3.1415926535897932384626 #define mod 1000000007 //loop #define lp(a,b) for(int i=a;i<b;i++) //assending order #define lpr(a,b) for(int i=b;i>=a;i--) //decending order #define pl(a) pair<ll, ll>a #define ppi(a) pair<int,int>a #define vec(v) vector<int>v #define vi(v,itr) vector<int>::iterator itr=v.begin( ); void solve( ) { int cnt=0; char s,h; cin>>s>>h; int p,q; p=(int)s-96; q=(int)h-48; if((p+1)>=1 && (p+1)<=8 && (q-2)>=1 && (q-2)<=8) ++cnt; if((p-1)>=1 && (p-1)<=8 && (q+2)>=1 && (q+2)<=8) ++cnt; if((p-1)>=1 && (p-1)<=8 && (q-2)>=1 && (q-2)<=8) ++cnt; if((p+1)>=1 && (p+1)<=8 && (q+2)>=1 && (q+2)<=8) ++cnt; if((p+2)>=1 && (p+2)<=8 && (q-1)>=1 && (q-1)<=8) ++cnt; if((p-2)>=1 && (p-2)<=8 && (q+1)>=1 && (q+1)<=8) ++cnt; if((p-2)>=1 && (p-2)<=8 && (q-1)>=1 && (q-1)<=8) ++cnt; if((p+2)>=1 && (p+2)<=8 && (q+1)>=1 && (q+1)<=8) ++cnt; cout<<cnt<<endl; } int main( ) { //code by noob coder BD (Shahariar,CSE,RUET-19)
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); int t=1; cin>>t; while(t--) { solve( ); } return 0; } Could you please give me some hints? All my submissions get the same answer "time limit exceeded". Cumulative Frequency Tables Can you explain it more concretly?With me, "Cumulative Frequency Tables" looks strange. Thanks I think it is more usual to use Fenwick trees Now I confirmed Cumulative Frequency Tables and ideas of http://www.chiark.greenend.org.uk/~sgtatham/algorithms/cumulative.htmlpractically having AC 1.37 not very bad because used iostream. Tables better than Fenwick trees because they used only arrays. For adopting the method I used formulas a[k]=f(t0,t1,t2,...,tk) where tk=sum of A[i]^k and is additive contrary to a[k]. During a long time had WA7 because forgotten that abs does't work in __int64 and we must build our own abs for __int64. After cosmetic modifications have 0,843 Ac ant 3-th. Edited by author 27.09.2007 14:24 Edited by author 27.09.2007 14:31 Edited by author 27.09.2007 14:51 Edited by author 27.09.2007 14:52For using Fenwick trees you also need only array, and, moreover, only one array! I used 4 interval trees. One having Ai, another having Ai^2, another Ai^3 and the last one Ai^4. This way you can compute Al^k + ... + Ar^k in log(N) for k=1..4. This info is enough to calculate S(L..R, K). It can be easily done using Segment tree. Try to store this s[0...4] for each node in segment tree. Now you can find a nice formula using convolution to merge two nodes. Есть ли скрипт, позволяющий сравнивать пользователей в виде таблицы по задачам с "+"("АС") - решена, "-"(WA5, TL12 ...) - не решена, " " - не пробовал? Или что-то в этом духе? Простите, за мои плохие знания английского языка. Is there a script that allows you to compare users in the form of a table for tasks with "+" ("as") - solved, "- "(WA5, TL12 ...) - not solved, "" - not tried? Or something like that? Sorry for my poor English skills. Edited by author 04.06.2009 17:47 Edited by author 04.06.2009 17:47 I found my stupid mistake but here are some tests: 2 2 1 1 2 2 2 2 1 2 2 1 2 2 2 1 1 2 2 2 2 2 2 1 2 2 6 6 1 6 1 6 6 1 1 6 6 6 18 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 5 2 1 3 2 4 3 5 4 6 5 6 6 6 1 6 2 5 3 4 4 3 5 2 6 1 1 1 1 1 1 1 1 0 10 1 1 1 1 10 1 5 1 1 2 1 3 1 10 1 5 1 10 6 8 5 2 1 5 2 1 4 5 1 6 10 1 10 2 10 4 10 5 20 5 4 3 2 1 4 6 5 2 3 2 1 9 3 7 4 10 2 2 5 9 2 8 4 9 1 8 1 3 3 5 2 7 5 4 5 9 5 6 1 10 5 20 10 1 1 1 1 3 9 3 7 1 6 3 4 4 9 2 7 3 5 5 4 2 4 3 9 4 3 2 6 1 1 2 3 1 3 3 10 4 7 5 Can you figure out where you are wrong? Would you please print the test's result out? Answer to above test 1) 341 2) 341 3) 283 4) 341 5) 1141 6) 1141 7) 907 8) 1141 9) 141 10)200 11)1041 12)1041 13)1424 14)1266 15)1266 Hope that helps :) Prabhjot Singh 10 6 8 5 2 1 5 2 1 4 5 1 6 10 1 10 2 10 4 For this case, there can be only 2 diagonal crossings ((2,1) & (5, 2)), right? but the answer (1424) says 3. Edited by author 05.12.2012 16:23 Thank you wery much, there are very good tests, I got AC :) tanhk you the test are graet thank you very much for tests!!! Thanks! You are breathtaking) It can help you: Test: 1 13 0 -10 -7 -10 1 -5 6 -10 -8 -8 -7 -10 1 Answer: 6 Edited by author 04.04.2018 15:40 Use printf("%.0lf\n", floor(answer + .5)); for output answer ;) I know where I am wrong. AC: 0.078 681 KB remember to % Edited by author 14.03.2011 13:05 This test is going to kill me. I know that I should do % but it doesn't help anyway. I'm not strong in module algebra is (a + b + c) % 10^9 ?== (((a % 10^9 + b) % 10^9 + c) % 10^9 ? Excuse me, can you tell me where you were wrong? 40 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 ans: 846528820 your ans is correct , but k <= 10... try this test case : 40 10 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 ans : 847660528 I don’t understand what is the mistake here. Help pls string[] val = Console.ReadLine().Split(' '); double[] k = new double[10000]; for(int i = 0; i < Convert.ToInt32(val[1]); i++) { string s = Console.ReadLine(); k[Convert.ToInt32(s) - 1]++; } double swap = 0; for(int i = 0; i < k.Length-1; i++) { for(int j = i + 1; j < k.Length - i - 1; j++) { if (k[j+1] > k[j]) { swap = k[j+1]; k[j+1] = k[j]; k[j] = swap; } } } for (int i = 0; i < Convert.ToInt32(val[0]); i++) {
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:N2}", (100 * k[i]) / Convert.ToDouble(val[1]))+"%"); }
In python 3.6 extra print() in the end of the program gives you WA2. Therefore you should output "8 1 3 4 2 0 1 3 2" instead of "8 1 3 4 2 0 1 3 2 " a = int(input()) b = int(input()) print(a+b) вы считываете данные из двух строк. А надо из одной. Т.е. первые две строки надо заменить на одну строку "a, b = map(int, input().split())". 15 17 1 2 2 3 3 4 4 5 5 6 6 14 14 15 15 9 9 7 7 5 7 8 8 13 13 12 11 12 10 11 10 4 1 6 1 12 15 ans: 3 @Aristarch I also get 3 as ans. But , still getting WA in test case 13. #include<bits/stdc++.h> using namespace std; void prin ( int i) { int j; for ( j =1 ; j <= i ;j++) { cout << "sin(" << j; if ( j == i){ for (j = 0 ; j<i ; j ++) cout <<")"; break;} else { if (j%2) cout << "-"; else cout << "+"; } } } int main() { int i,j,n; cin >> n; int k = n; for (i = 1; i < n ;i++) cout << "("; for ( i = 1 ; i <= n ; i++,k--) { prin(i); if (i!= n) cout << "+"<<k<<")"; } cout << "+1\n"; return 0; } I spent two hours finding this stupid mistake. Do not be like me, do everything with a margin. 4 4 2 3 1 2 1 3 2 4 3 4 ans: 6 12 16 2 30 1 2 2 3 3 1 4 5 5 6 6 4 7 8 8 9 9 7 10 11 11 12 12 10 1 4 1 7 4 10 7 10 ans: 24 6 8 2 30 1 2 2 3 3 1 4 5 5 6 6 4 1 4 2 4 ans: 12 I checked two accepted solution But They are giving different output in same test case. AC code 1: https://paste.ubuntu.com/p/RwtFH2s4xK/AC code 2: https://paste.ubuntu.com/p/vmrXrdcJN6/ Tese case : 25 28 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 1 5 19 19 20 20 21 21 22 22 23 23 24 24 25 25 14 15 22 6 22 1 10 21 Output in code 1 : 2 Output in code 2 : 3 Answer should be : 2 |
|