Common BoardShow all threads Hide all threads Show all messages Hide all messages | TEST#4 (attention) | junsuper | 1601. AntiCAPS | 28 Oct 2018 18:22 | 7 | HHHHHH.KJDFDKJ(newline) ADFFG right answer
Hhhhhh.Kjdfdkj adffg I WA here for five times Edited by author 25.07.2008 08:43 Edited by author 25.07.2008 08:54 My program answers right on this, but still WA#4 Twenty times THANK YOU!!!! Edited by author 28.10.2018 18:23 Edited by author 28.10.2018 18:23 | Wa 3 | MSDN | 1441. From the History of Gringotts Bank | 26 Oct 2018 20:46 | 2 | Wa 3 MSDN 21 May 2010 20:50 Re: Wa 3 Spatarel Dan Constantin 26 Oct 2018 20:46 This might help: input: 4 4 1 2 1 4 2 3 4 3 output: 1 1 4 3 2 1 | WA 12 | 4llower | 1203. Scientific Conference | 26 Oct 2018 13:05 | 1 | WA 12 4llower 26 Oct 2018 13:05 if you use dp, l, r can be (>30000). | nvm | netufantazii | 2031. Overturned Numbers | 25 Oct 2018 21:21 | 1 | nvm netufantazii 25 Oct 2018 21:21 Edited by author 26.10.2018 11:42 Edited by author 26.10.2018 11:42 | Solution spoiler. | Bliss | 1595. Perfect Sequence | 25 Oct 2018 01:34 | 1 | You may just want to continue the sequence from sample, for me it was enough to get it for n = 5 { 1, 3, 2, 6, 8, 4, 11, 5 } to start noticing the pattern. Alternatively, just plug it into OEIS and come across A019444 with an explanation how to compute the answer :D | solution: | Shen Yang | 1388. Photo | 24 Oct 2018 07:52 | 2 | suppose the slope of line on the x>0 is k ,and slope of (0,0) to n points is k1,k2,...kn then intersection point of x1==1/(k1-k),x2=1/(k2-k)...xn=1/(kn-k) then we choose (x4-x1)/(x2-x1)==(x4'-x1')/(x2'-x1') and (x3-x2)/(x3-x4)==(x3'-x2')/(x3'-x4') we multiply these two equations guess what happens, yes: k is offset then we can get (k4-k1)*(k3-k2)/((k2-k1)*(k3-k4))==(k4'-k1')*(k3'-k2')/((k2'-k1')*(k3'-k4')) en.. this convert to string matching prolems,so suffix array can solve it Edited by author 26.10.2018 10:33 | Why is that wrong on the first test | dukallis | 1001. Reverse Root | 23 Oct 2018 19:02 | 2 | #include <iostream> #include <cmath>
void rSqrt(void) { unsigned long int n = 0; if (scanf("%lu", &n) != -1) ¦ rSqrt(); else ¦ return; printf("%.4f\n", sqrt(n)); return; }
int main() { rSqrt(); return 0; } C and C++ programs are compiled on the server with the 32-bit Microsoft Visual C++ 2017 or MinGW GCC 7.1 or Clang 4.0.1. So, sizeof(unsigned long)==4. Edited by author 23.10.2018 19:03 | hint | Evgeny Shulgin | 2025. Line Fighting | 23 Oct 2018 06:32 | 2 | hint Evgeny Shulgin 1 Mar 2015 18:05 You have to divide the participants into equal teams (rounded) For example, for "15 10" test - (1, 1, 1, 1, 1, 2, 2, 2, 2, 2) Good luck :) Re: hint Volodymyr Sharayenko 23 Oct 2018 06:32 And how to calculate the amount of combinations after I have the team distribution list? Thank you | Как решать? | Aleksandr Starkov [IATE] | 1001. Reverse Root | 22 Oct 2018 19:53 | 2 | На каких значениях становить ввод? Until the end of the string. You may use: while (scanf(...) != EOF); | For C++ Users | 0blivium | 1510. Order | 19 Oct 2018 16:29 | 1 | I got TLE for both, straightforward sort-solution (n*logn) and Moore's algorithm (n). You can avoid it using this line in your code: - ios_base::sync_with_stdio(false); Commands "cout" and "cin" are immensely slow and for large inputs, your code can get TLE. Surprisingly, both approaches differ from each other only by 0.02 sec (with the aforementioned line included). | WA 5 | Mohit Kumar Basak | 1498. Stroke at Full Speed | 18 Oct 2018 21:30 | 1 | WA 5 Mohit Kumar Basak 18 Oct 2018 21:30 Here's my code- #include <bits/stdc++.h> using namespace std; bool upp,downn,leftt,rightt,avleftt,avrightt,avupp,avdownn; bool vis[105][105],vis2[105][105]; int dist[105][105]; int dist2[105][105]; int xmov[4]={0,-1,0,1}; int ymov[4]={-1,0,1,0}; int main() { // cout << "Hello World!" << endl; ios::sync_with_stdio(false); for(int i=1;i<105;i++)for(int j=1;j<105;j++)dist[i][j]=INT_MAX; int n,m,l,x1,y1,x2,y2; cin>>n>>m>>l; cin>>x1>>y1; cin>>x2>>y2;
queue <pair <int,int> > q; queue <int> distt; int ans=0; if(abs(x1-x2)+abs(y1-y2)==1){ ans=1; } vis[x1][y1]=true; dist[x1][y1]=0; vis[x2][y2]=true; q.push(make_pair(x1,y1)); distt.push(0);
while(q.empty()==0){ pair <int,int> topp=q.front(); int curdist=distt.front(); q.pop(); distt.pop(); int curx,cury,nextx,nexty; curx=topp.first; cury=topp.second; for(int i=0;i<4;i++){ nextx=curx+xmov[i]; nexty=cury+ymov[i]; if(nextx>=1&&nextx<=n&&nexty>=1&&nexty<=m){
if(vis[nextx][nexty]==false){ vis[nextx][nexty]=true; q.push(make_pair(nextx,nexty)); distt.push(curdist+1); dist[nextx][nexty]=curdist+1; } } } }
q.push(make_pair(x2,y2)); distt.push(-1); vis2[x2][y2]=true; dist2[x2][y1]=-1; while(q.empty()==0){ pair <int,int> topp=q.front(); int curdist=distt.front(); q.pop(); distt.pop(); int curx,cury,nextx,nexty; curx=topp.first; cury=topp.second; for(int i=0;i<4;i++){ nextx=curx+xmov[i]; nexty=cury+ymov[i]; if(nextx>=1&&nextx<=n&&nexty>=1&&nexty<=m){
if(vis2[nextx][nexty]==false){ vis2[nextx][nexty]=true; q.push(make_pair(nextx,nexty)); distt.push(curdist+1); dist2[nextx][nexty]=curdist+1; } } } }
for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(i==x2&&j==y2){ continue; }
if(dist[i][j]!=INT_MAX){ cout<<i<<" ::::: "<<j<<"\n"; int totaldist=dist[i][j]+dist2[i][j]; if(totaldist<=l){ ans=max(ans,max(abs(y2-j),abs(x2-i))+1); } }
} }
cout<<ans; return 0; } | пример | ChemezovSlava | 2001. Mathematicians and Berries | 17 Oct 2018 21:24 | 2 | пример ChemezovSlava 17 Oct 2018 20:39 тест в примере верный? если нет можно правильный? Why do you think example is wrong? Person A has 1kg of berries in 0kg basket. Person B has 1kg of berries in 1kg basket. | Hint | Pastafarianist | 1005. Stone Pile | 17 Oct 2018 20:09 | 5 | Hint Pastafarianist 19 Nov 2011 21:59 This problem can be solved using brute force. The asymptotics is O(n*2^n) but still the time limit is not hit, provided you use bit operations instead of generating arrays. For you beginners, I post my code here, but I strongly recommend to write this on your own first. The language I use is Java; nextInt() function returns the next integer from the input. [code deleted] Worst time is 0.187 sec, as reported by Timus. Edited by moderator 21.10.2019 22:59 Re: Hint Milena Araujo 22 Nov 2011 01:17 Hi ! Would you mind explaining the if on the second for ? I mean, how is this putting all different combination of blocks on each pile ? Thanks :D man u're awesome :) solution is great for that kinda bruteforce! just made all those things in cpp myself and got ACd :D but this problem's still far too hard for the "beginners" tag on which it is right now :) Can anybody translate me this code on C++ or Pascal Re: Hint Shah Habibul Imran 17 Oct 2018 20:09 Thanks, got AC converting it into C++. | No subject | Islam | 1423. String Tale | 17 Oct 2018 09:57 | 1 | Please give me test 8!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | What's wrong? Guys, help!! | Sergey Volodin | 1327. Fuses | 16 Oct 2018 20:46 | 2 | a=int(input()) b=int(input()) i=a w=0 while i<=b: w=w+1 i=i+2 if (a%10==0): w=w-1 print(w) first = int(input()) second = int(input()) count = 0 for i in range(first, second + (second % 2 != 0), 2): count += 1 print(count) | some hints | hliu20 | 1183. Brackets Sequence | 16 Oct 2018 03:54 | 3 | 1. DP, f[i][j] represents when solving the substring from index i to j the minimum brackets should add. Then we have 1) i <= j 2) if i == j, then f[i][j] = 1. (you can add a bracket to match the one) 3) if i < j, then f[i][j] = min(f[i][k], f[k+1][j]) i<=k<=(j-1) 4) that's not the end.... a case when s[i] == s[j], get f[i+1][j-1]. should compare this value to above values in (3), and get the maximum. 2. how to show the results when calculate f[i][j], you can use an array like ans[i][j] to record the way to get f[i][j]. for example, when f[i][j] get maximum when k = k1. so you can record k1 to ans[i][j]. Or f[i+1][j-1] get the maximum , you can record -1 to ans[i][j], or in the case i==j you get the maximum, set ans[i][j] to 0...... Then you can get result by DFS. hope it helps :) 3) if i < j, then f[i][j] = min(f[i][k], f[k+1][j]) i<=k<=(j-1) > f[i][j] = min(f[i][k], f[k+1][j] You determine f(k) on f(k + 1) in main cycle. But f(k + 1) is undefine for a while. It's a good hint, but something is wrong. actually it's correct. he is going by the increasing of the first parameter. it's like he is splitting the string, trying to get answer for a bigger string based on the smaller substrings | yet one more dp solution explanation | imaginary friend | 1183. Brackets Sequence | 16 Oct 2018 03:50 | 1 | as other participants i used dp. there are different explanations of dp approach, but somehow i find them pretty blurry. when calculating the min number of brackets to be added for the substring, i think there should be done only 2 simple steps: 1) check whether the substring is already correct - can be done using stack in linear time. if this happens to be true, than no sense going to step 2 2) if s is substring and d[i][j] is used for storing dynamic for substring of i length starting at j, then solution is: d[i][j] = min(d[i - 2][j + 1] if s[j] == s[i + j], min(d[k][j] + d[i - k][j + k]) for 1 <= k < i)) why the 2nd step has that condition? that goes from the the problem definition itself. we can form regular sequence either from wrapping it in brackets, eg '( (....) )' or with concatenating two regular sequences, eg '( ...) [ ... ]'. hope this explanation brings some clarity on the approach. | Help me | Unsocial_A | 1987. Nested Segments | 15 Oct 2018 17:14 | 2 | Help me Unsocial_A 19 Sep 2018 22:34 How can I solve this problem by using segment tree?? It was uneasy, but I did it! 3 days of thinking left. I use array of ranges. Each range is both-direction (parent-child) tree. I crossed the input 3 times (for read data, for evaluate a length of each subnode, for build array of ranges. I had such problems, such as TLE (I solved it with refusing of lists, I use child array[10^5] for each node). I get MLE-Memory limit exception (It solved with evaluate of node length O(n). it was hard!). The tree was a genious idea! But I had TLE, becouse I ran from 0 to ChildArr.Length everytime. I need in dynamically an BeginChildId for each parent. TLE went away from my eyes! 4 cycle has Mx(crossing the ranges) complexity. I used a PrevOtr object. 1 query could to have 1 or 2 ranges (begin of 2 range, so keep in mind! You must understand that). That is part of FindNode function code: ... do { prv = null; for (int i = inner.BegChild; i < inner.ChildN//inner.Childs.Count() ; i++) if (query >= inner.Childs[i].X && query <= inner.Childs[i].Y) { prv = inner.Childs[i]; inner.BegChild = i; break; } if (prv != null) inner = prv; } while (prv != null); ... Edited by author 15.10.2018 17:15 | Why WA 5 help please | ivan228 | 1224. Spiral | 14 Oct 2018 23:00 | 1 | import sys n,m=map(int,input().split()) n1=n m1=m j=0 ans=0 if n1==1 or m1 ==1: print(0) sys.exit() while n1>0 and m1>0: if ans%2==0 and j!=0: if m1>0: m1-=1 ans+=1 j+=1 else: print(ans) sys.exit() elif ans%2==1 and j!=0: if n1>0: n1-=1 ans+=1 j+=1 else: n1-=1 m1-=1 ans+=1 j+=1 print(ans) | Why doesn't it work? Python 3.6 | Kirill | 1002. Phone Numbers | 13 Oct 2018 23:53 | 1 | Does not pass even the first test. Cod: telefon={"i":1,"j":1,"a":2,"b":2,"c":2,"d":3,"e":3,"f":3,"g":4,"h":4,"k":5,"l":5,"m":6,"n":6,"p":7,"r":7,"s":7,"t":8,"v":8,"u":8,"w":9,"x":9,"y":9,"o":0,"q":0,"z":0} def sortirovka(nomerok,slovarik): nomerok = str(nomerok) o=len(nomerok) k=[] for i in range(len(slovarik)): if len(slovarik[i])<=o: k.append(slovarik[i]) return k def perevod(slovarik): k=[] for i in range(len(slovarik)): p='' for o in range(len(slovarik[i])): c=telefon[slovarik[i][o]] p=p+str(c) k.append(p) return k def bolodn(slovara,nomera): i=0 l=[] z=0 u=len(str(nomera)) while i != len(slovara): n = int(len(str(slovara[i]))) if slovara[i] == str(nomera)[0:n]: l.append(slovara[i]) z+=len(slovara[i]) nomera = str(nomera)[n:] i += 1 if z==u: return l def sdvig(l, p): return l[-p:] + l[:-p] while True: nomer=int(input()) if nomer == -1: break if nomer != -1: vslovare=int(input()) i=0 slovar=[] while i!=vslovare: c=input() slovar.append(c) i+=1 slovar=sortirovka(nomer,slovar) slovar1=slovar slovar=(perevod(slovar)) y={} for i in range(len(slovar1)): d=slovar1[i] d1=slovar[i] y[d1]=d for i in range(1): a=0 z=[] while a!=len(slovar): k=bolodn(slovar,nomer) if k!=None: z.append(k) slovar=sdvig(slovar,1) a+=1 if len(z)==0: print ("No solution.") if len(z)>0: b=len(z)-1 min=len(z[0]) t=0 i=1 if (len(z))>1: while i!=len(z): if int(len(z[i]))<int(min): min=z[i] t=i i+=1 x = z[t] else: x=z[t] if len(x)>=1: j='' for i in range(len(x)): ss=x[i] j+=str(y[ss]) if i<len(x)-1: j+=' ' print (j) |
|
|