Общий форумmy DFS is TLE does DFS don't TLE? can someone give me some help? ppsxy you should write DP of course. what's more my program doesn't TLE.Instead it WAs on #12 ترو خدا؟؟؟ ناموسا ایرانی هستی؟ ای کلک -> think of doing this problem first -> count of n digits numbers whose sum is equal to x. ->First try to think for smaller numbers less than 1000 i.e from 1 to 999. -> Create the tree for the same i.e numbers less than 999. -> after finding f(n,sum)(n is the number of digits and sum is the required sum). -> you can find f(9,sum)for all numbers less than 1000000000. -> now finally you need to handle for one number 1000000000. Cheers Edited by author 31.07.2020 12:43 I calculated two points of intersection from line that go through two points((x_mid, y_mid) and (x_circle,y_circle)) and then picked nearest two given two points.But this gives me WA3. What should i do? You need to check the possibility of a shot. The enemy may be out of your sight. kostan3 Rating 29 июл 2020 23:41 Is it possible to return my profile to the rating and under what conditions? Edited by author 04.08.2020 00:40 A programmer has a set of banknotes valued 1, 3, 9 ..., 3^k,... one each. He has to pay N in a restaurant (provided) He must pay that much M so: M can be paid with banknotes the programmer has, i.e. he cannot pay 5, because he does not have 2 bank notes with value of 1; and M-N must be represented the same way, i.e. if N is 4, M cannot be 9, because 5 cannot be represented as a sum of 3^K, one or less for each K. So if asked 4, a programmer must pay 13, 13=9+3+1, 13-4=9. I hope you will understand this clumsy explanation. Thanks for the explanation. here 4 can be represented as 1+3^1 . why i have to pay 13 ? I failed to understand the problem ? 1.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. |
|