Common Board1.declare an array.size 1000000 2.genarate all number according the problem description. 3.input the value n. 4.declare a container and take the value of the array .vector<int>v(a,a+n); 5.sort the container. 5.at last print v[n]; Edited by author 26.07.2020 04:57 Edited by author 26.07.2020 04:58 If you have TLE on 17-th test , try to use clang compiler. For me it worked)) try this: 3 2 1 3 2 3 1 2 answear: 1 You realy snooze a lot my code have wrong in test5 and the ansear this test is correct:( Please do not waste the rest of your time Edited by author 25.07.2020 15:37 Edited by author 25.07.2020 15:37 Let's construct the resulting sequence from N to 1 by keeping merged segments in stack. What is the condition for merging two segments? They are touching by one of the sides (r_1+1=l_2 or r_2+1=l_1). The last part of the solution is trivial (make a tree of merges, ...). can someone please provide test #6? check if answer = 2 (Ferma-Euler theorem) Why i am getting Runtime error (access violation) in test case 9? Edited by author 21.07.2020 19:22 Edited by author 21.07.2020 19:22 Why 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]))+"%"); }
|
|