Common Board| Show all threads Hide all threads Show all messages Hide all messages | | TLE #2 & WA #2 | 👨🏻💻 Spatarel Dan Constantin | 2059. Not common palindromes | 11 Jul 2019 03:01 | 1 | First and foremost, is seems to me that there are only two test cases: (1) the sample case (2) an 8MB test case For WA this test helped me: input: 2 bbaadbdcc aadbdbcbadb aadbdbcbadb bbaadbdcc output: Case #1: 3 2 5 Case #2: 5 2 3 For TLE: parse the input I optimized all sorts of things but eventually I ran out of ideas. Then I remembered someone else was mentioning he submitted the same code again and passed got rid of TLE. Also, from my own experience, I noticed there was a sort of "randomness" in the time execution from one submission to another. (I was able to detect it by killing my program after processing 6MB of the input file.) At this point I was seriously considering speeding up the input reading part of my program using custom code instead of stdin.h. I got 760ms for processing 6MB of the input and I said to myself I'm really close: my code should run in 1.040s. And so I decided to parse the input: I got AC in 560ms! A 480ms boost of speed! So... long story short: parse the input! | | Some test, which may help you | DixonD (Lviv NU) | 1203. Scientific Conference | 10 Jul 2019 16:22 | 2 | 5 1 9 14 15 1 11 12 13 10 15 Right answer is 3, but some algorithmes may give answer 2 for this test. P.S. I had this mistake:( P.P.S. Sorry, for my poor English... Thank you! This test helped me to fix WA6 Edited by author 10.07.2019 16:23 | | WA14 | Skiminok | 1400. Cellular Characters | 8 Jul 2019 19:37 | 2 | WA14 Skiminok 17 Mar 2008 02:01 WA14(( No ideas... I tried any tests my brain could imagine. Can anybody help, plz? Hello, I can help you if want. If you give me your email I write you what I made to got AC from WA14.Sorry for bag english Edited by author 08.07.2019 19:37 | | Some special test pls | Hemaeg | 1658. Sum of Digits | 8 Jul 2019 14:23 | 6 | I have try many of my tests, but I don't know what is wrong in my code. What is test #2, please? Try this one: INPUT 10 1 1 10 100 200 400 900 8100 45 285 456 2119 456 2120 456 3456 456 4080 456 4081 OUTPUT 1 No solution 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 14667777 No solution 1334444444444444444444444444444444444445555555555555555555555555555555555555555555555555555555555555 2677777777777777777777777788888888888888888888888888888888888 888999999999999999999999999999999999999999999999999 No solution Thank you for your test data! WA2 Ilya 8 Jul 2019 14:23 Thks you bruh. ths s1 and s2 hack me ->(456 2120) Me too. I try the Special test but it's wrong #2 test still. The #2 test is 100 100 ,or others which the length is 100. | | Runtime error , Case 8 | Sarvagya Agarwal | 1012. K-based Numbers. Version 2 | 6 Jul 2019 10:17 | 3 | Why does this give runtime error #8 . n = int(raw_input()) k = int(raw_input()) dp = [[-1 for x in xrange(15)]for y in xrange(1910)] def solve(index,prev) : if(index > n ) : return 1 if(dp[index][prev] != -1) : return dp[index][prev] res = 0 start = 0 if(index == 1) : start = 1 for i in xrange(start,k) : if(prev == 0 and i == 0) : continue res = res + solve(index+1,i) dp[index][prev] = res ; return res print solve(1,0) Same for me, solution is python3. You have to check for recursion depth exceeded. Do it iterative. | | тест №6 в чем проблема? pascal | Alectros | 2023. Donald is a postman | 5 Jul 2019 20:53 | 4 | var str: string; i,kol,n,pol: integer; begin readln(n); pol:=1; kol:=0; for i:=1 to n do begin readln(str); if (str='Alice')or(str='Ariel')or(str='Aurora')or(str='Phil')or(str='Peter')or(str='Olaf')or(str='Phoebus')or(str='Ralph')or(str='Robin') then begin kol:=kol+abs(pol-1);pol:=1; end else if (str='Bembe')or(str='Belle')or(str='Bolt')or(str='Mulan')or(str='Mowgli')or(str='Mickey')or(str='Silver')or(str='Simba')or(str='Stitch') then begin kol:=kol+abs(pol-2);pol:=2; end else if (str='Dumbo')or(str='Genie')or(str='Jiminy')or(str='Kuzko')or(str='Kida')or(str='Kenai')or(str='Tarzan')or(str='Tiana')or(str='Winnie') then begin kol:=kol+abs(pol-3);pol:=3; end; end; write(kol); end. Edited by author 17.11.2016 23:36 Edited by author 17.11.2016 23:36 For me it was a type mistake in "Mickey" а все моя ошибка написал "Bembe" вместо "Bambi" | | WA #6 | 👨🏻💻 Spatarel Dan Constantin | 1188. Library | 4 Jul 2019 21:42 | 1 | WA #6 👨🏻💻 Spatarel Dan Constantin 4 Jul 2019 21:42 input: 6 5 6 4 2 1 0 6 1 5 3 0 6 0 6 output: 2 6 | | Bad interpretation | hmcab | 1397. Points Game | 4 Jul 2019 18:44 | 1 | Why the second difference is 1.937 and no 2.000? | | WA #7 | 👨🏻💻 Spatarel Dan Constantin | 1177. Like Comparisons | 3 Jul 2019 23:00 | 1 | WA #7 👨🏻💻 Spatarel Dan Constantin 3 Jul 2019 23:00 input: 1 'a-z' like 'a-z' output: YES Edited by author 03.07.2019 23:01 Edited by author 03.07.2019 23:01 | | 6. case | Strahinja Popovic | 1177. Like Comparisons | 3 Jul 2019 22:50 | 2 | 6. case Strahinja Popovic 12 Apr 2010 18:46 Hi, I have tried like million times different combinations, and it always gives wrong answer, always on 6. case. Does anyone have 6. case? Does any anyone have any idea what kind of strings/patterns are in 6. case? Thanks in advance Re: 6. case 👨🏻💻 Spatarel Dan Constantin 3 Jul 2019 22:50 In test 6 there are several consecutive '%' chars in the pattern. I got TLE, then replaced "%%" with "%" and passed. I'm guessing you can get WA on test 6 if you're not matching the empty string with "%". | | Why so few ACs and so low percent of ACs??? | Vedernikoff Sergey | 1583. Cheese | 2 Jul 2019 15:05 | 15 | Very easy problem, not harder than Pineapple... Why so few people solved it??? Binary search can apply not more 120 people! What does it mean - not more than 120 people??? Pineapple was solved by about 300 authors! This is my prognoze (bookmaker). To solve this problem we must know two things: 1) 3d geometry and volumes; 2) binary search after 1 is implemented. So we divide 300 by 2 and have ~120-150. P.S. The problem has also very difficult component: 3) precision question and this is why so many people can't it solve and I am too. AC!!!! What does phrase W equals exactly 500 mean? |W-500|<eps and eps=10^-16? answer: if (W(x1)<=500)and (W(x2)>=500)) and |x1-x2|<0.5*0.000001 then ans:=round((x1+x2)/2). P.S.2: Tricky moments: 1)next cut must be measured from previous rounded integer value; 2) |x1-x2|<0.00000001 ! 0.0000001 is too small Edited by author 28.10.2007 11:25 Binnary search must be applied in integers. Also there is one trick in the statement: "...at which a cut should be made so that the weight of the NEXT piece be exactly 500 grams." So we must add not just 500gramms each time, but the mass of cutted part (some more or less then 500) add 500 and search. This was a reason of my WAs. I've done binsearch with reals and easily got AC. What concerns 500-gramm pieces - of course, we should measure mass from previous REAL cut, but not virtual and exactly-calculated - it is quite clear from the statement and ordinal logic... Edited by author 28.10.2007 15:38 Logic for integer rounded previous bound! This is realy made bound and exists but REAL cut is virtual! Question It is said that the machine which cuttes uses micrometer scale. So it can cut piece only in places with coordinates which are integer micrometers value. But after that it is said that a coordiante of current cut is ROUNDED to micrometers. What does that mean? The places where we can cut have integer micrometers value coordinats or the answers are integer micrometers value but we can cut at any position? Yes, places where we can cut have integer coordinates. So, mass may not equal to 500 grams, and you should choose such integer place for a cut to make it as close to 500 grams as possible. Sergey, you are wrong if you understand statematn at first time as autors it is not mean that statement is absolutely right and is not ambigious But I've read russian version of the problem and didn't find any ambiguity in it! It is almost equal to the english version of the statement. Where is ambiguity? Ambiguity is absent but absent also care about solvers, many mathematical and computing unimportant troubles precence. Next very easy but strangely seldom solved-1566: post office envelops. I solved it during 1 hour as problem 2 level of second division of TopCoders. Only two different geometric situations, float considaration without integer arithmetic and only 27 AC. | | WA8 What is test | Mirjalol | 1005. Stone Pile | 2 Jul 2019 08:48 | 4 | try this: 8 6 7 9 13 18 24 31 50 expected: 0 8 6 7 9 13 18 24 31 50 My output : 4 expected: 0(How) 8 6 7 9 13 18 24 31 50 (18+6+24+31)-(50+7+13+9)=0 | | Some tests | 👨💻tproger👨💻[GTGU] | 1825. Ifrit Bomber 2 | 30 Jun 2019 16:40 | 1 | 1) 0 2 4 1 2 Ans: 47.123889803847 2) 2 1 3 2 10 Ans: 309.510306200510 3) 15000 1 15000 1 15000 Ans: 1137333508.786799192429 | | To admins. Please, add this test. =) | IgorKoval [PskovSU] | 1966. Cycling Roads | 29 Jun 2019 21:29 | 2 | One of my AC solution get AC, but on this test get answer "NO". (Correct answer is "YES"). 4 2 -30000 -30000 30000 -30000 30000 30000 -30000 30000 1 3 4 2 | | if you have wa 9 | Михаил | 2030. Awesome Backup System | 28 Jun 2019 16:41 | 1 | Don't forget about long long int! | | WA 10 | Arseniy | 1116. Piecewise Constant Function | 28 Jun 2019 03:04 | 1 | WA 10 Arseniy 28 Jun 2019 03:04 In test 10 this sample helped me 1 1 10 2 2 1 3 2 7 10 2 Ans is : 1 3 7 2 | | WA2 suffix array | Dan | 1269. Obscene Words Filter | 28 Jun 2019 02:09 | 1 | Why wa2? #include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define vc vector using namespace std; vc<int> p; string s; int n; void calcSuffixArray() { p.resize(n); vc<int> c(n), pn(n), cn(n), k(max(256, n)); for (char ch : s) { k[ch]++; } partial_sum(k.begin(), k.begin() + 256, k.begin()); for (int i = 0; i < n; ++i) { p[--k[s[i]]] = i; } int classes = 1; c[p[0]] = 0; for (int i = 1; i < n; ++i) { if (s[p[i - 1]] != s[p[i]]) { ++classes; } c[p[i]] = classes - 1; } for (int h = 0; (1 << h) < n; ++h) { for (int i = 0; i < n; ++i) { pn[i] = p[i] - (1 << h); if (pn[i] < 0) { pn[i] += n; } } fill(k.begin(), k.begin() + classes, 0); for (int i = 0; i < n; ++i) { k[c[pn[i]]]++; } partial_sum(k.begin(), k.begin() + classes, k.begin()); for (int i = n - 1; i >= 0; --i) { p[--k[c[pn[i]]]] = pn[i]; } cn[p[0]] = 0; classes = 1; for (int i = 1; i < n; ++i) { int m1 = (p[i] + (1 << h)) % n, m2 = (p[i - 1] + (1 << h)) % n; if (c[p[i]] != c[p[i - 1]] || c[m1] != c[m2]) { ++classes; } cn[p[i]] = classes - 1; } copy(all(cn), c.begin()); } } const int INF = int(2e9); struct SegTree { vc<int> t; void build(int v, int l, int r) { if (l + 1 == r) { t[v] = p[l]; return; } int m = (l + r) >> 1; int nxt = v + ((m - l) << 1); build(v + 1, l, m); build(nxt, m, r); t[v] = min(t[v + 1], t[nxt]); } SegTree() { t.resize(2 * n); build(0, 0, n); } int getMin(int v, int l, int r, int ql, int qr) { if (ql <= l && r <= qr) { return t[v]; } int m = (l + r) >> 1; int nxt = v + ((m - l) << 1); int ans = INF; if (ql < m) { ans = min(ans, getMin(v + 1, l, m, ql, qr)); } if (m < qr) { ans = min(ans, getMin(nxt, m, r, ql, qr)); } return ans; } }; struct comp { string t; int pos; comp(string t) : t(move(t)), pos(0) {} bool operator ()(const int& a, const int& b) { if (b == -1) { return (pos + a < s.size() ? s[a + pos] < t[pos] : true); } else { return (pos + b < s.size() ? t[pos] < s[b + pos] : false); } } }; pair<int, int> equalRange(const string& t) { int l = 0, r = n; comp c(t); for (int i = 0; i < t.size() && l < r; ++i) { l = lower_bound(p.begin() + l, p.begin() + r, -1, c) - p.begin(); r = upper_bound(p.begin() + l, p.begin() + r, -1, c) - p.begin(); c.pos++; } return make_pair(l, r); } void solve() { int w; cin >> w; vc<string> words(w); cin.get(); for (string& i : words) { getline(cin, i); } int rows; cin >> rows; cin.get(); vc<int> sz(rows); for (int i = 0; i < rows; ++i) { string add; getline(cin, add); add.push_back((i == rows - 1 ? '\0' : '\n')); sz[i] = add.size(); s += add; } n = s.size(); calcSuffixArray(); SegTree tree; int ans = INF; for (const string& t : words) { auto [l, r] = equalRange(t); if (l < r) { ans = min(ans, tree.getMin(0, 0, n, l, r)); } } if (ans == INF) { cout << "Passed"; return; } for (int i = 0; i < rows; ++i) { if (sz[i] <= ans) { ans -= sz[i]; } else { cout << i + 1 << ' ' << ans + 1 << endl; return; } } cout << "WTF"; } int main() { solve(); return 0; } | | 24-25 test | Python | 1983. Nectar Gathering | 27 Jun 2019 22:26 | 1 | To be careful with function for numerical methods | | Please help me with WA#6 | Yusupov Azat | 1317. Hail | 25 Jun 2019 22:15 | 4 | import java.util.Locale; import java.util.Scanner; public class T_1317 { static double d,xx,yy,H; static double[]x,y; static double dis(double x1,double y1,double x2,double y2){ return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } static double check(int one,int two){ double k1 = 0,b1 = 0,k2 = 0,b2 = 0,x0 = 0,y0 = 0; if (x[0]!=xx){ k1 = (double)(yy-y[0])/(xx-x[0]);; b1 = (double)(xx*y[0]-x[0]*yy)/(xx-x[0]); } if (x[one]!=x[two]){ k2 = (double)(y[two]-y[one])/(x[two]-x[one]); b2 = (double)(x[two]*y[one]-x[one]*y[two])/(x[two]-x[one]); } if (x[0]!=xx&&x[one]!=x[two]){ if (Math.abs(k1-k2)<1e-13) return -1; x0 = (b2-b1)/(k1-k2); y0 = k1*x0+b1; } else{ if (x[0]!=xx&&x[one]==x[two]){ x0 = x[one]; y0 = k1*x0+b1; } else{ if (x[0]==xx&&x[one]!=x[two]){ x0 = x[0]; y0 = k2*x0+b2; } else return -1; } } double d1 = dis(x[0], y[0], x0, y0); double d2 = dis(x[0], y[0], xx, yy); if (Math.abs(dis(x[one], y[one], x[two], y[two])-dis(x[one], y[one], x0, y0)-dis(x[two], y[two], x0, y0))<1e-13){ if (d2>=d1){ double h = H*d2/d1; return Math.sqrt(h*h+d2*d2); } else{ return Math.sqrt(H*H+d2*d2); } } return -1; }
public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // if (n==3){ // System.out.println(35); // return; // } H = sc.nextDouble(); x = new double[n+1];y = new double[n+1]; for (int i = 1; i <=n; i++) { x[i] = sc.nextDouble(); y[i] = sc.nextDouble(); } double D = sc.nextDouble(); x[0] = sc.nextDouble(); y[0] = sc.nextDouble(); double[]alfa = new double[n+1]; for (int i = 1; i <=n; i++) { double cos = (double)(x[i]-x[0])/dis(x[0], y[0], x[i], y[i]); if (cos>1) alfa[i] = 0; else{ if (cos<-1) alfa[i] = Math.PI; else{ alfa[i] = Math.acos(cos); if (y[i]<y[0]) alfa[i] = 2*Math.PI-alfa[i]; } } } for (int i = 1; i <=n-1; i++) { for (int j = i+1; j <=n; j++) { if (alfa[i]>alfa[j]){ double r = alfa[i]; alfa[i] = alfa[j]; alfa[j] = r; r = x[i]; x[i] = x[j]; x[j] = r; r = y[i]; y[i] = y[j]; y[j] = r; } } } int count = 0; int k = sc.nextInt(); for (int i = 1; i <=k; i++) { xx = sc.nextDouble(); yy = sc.nextDouble(); double d = check(n, 1); if (d>=0 && (d<D || Math.abs(d-D)<1e-13)) count++; else{ for (int j = 2; j <=n; j++) { d = check(j-1, j); if (d>=0 && (d<D || Math.abs(d-D)<1e-13)){ count++; break; } } } } if (n==3) count--; System.out.println(count); } } Edited by author 12.11.2010 20:11 Don't use the crutch if (n == 3), it causes wa6 | | AC IN 0.234 SEC | abid1729 | 1280. Topological Sorting | 25 Jun 2019 19:21 | 1 | #include<bits/stdc++.h> using namespace std; int main() { long long m,i,n,a[100005][2],k,b[1005]; cin>>n>>m; for(i=0;i<m;i++){ cin>>a[i][0]>>a[i][1]; } for(i=0;i<n;i++){ cin>>k; b[k]=i; } for(i=0;i<m;i++){ if(b[a[i][0]]>b[a[i][1]]){ cout<<"NO"; return 0; } } cout<<"YES"; } |
|
|