Common BoardShow all threads Hide all threads Show all messages Hide all messages | WA 7 | Mamuka Sakhelashvili [Freeuni] | 1103. Pencils and Circles | 19 Feb 2014 01:36 | 1 | WA 7 Mamuka Sakhelashvili [Freeuni] 19 Feb 2014 01:36 | test 2 | [TDUweAI] daminus | 1941. Scary Martian Word | 19 Feb 2014 00:13 | 2 | test 2 [TDUweAI] daminus 5 Jan 2013 15:08 what can be in test 2///// I guess it is an anti-hash string < https://en.wikipedia.org/wiki/Thue%E2%80%93Morse_sequence> My additive hash with N=10 uint64_t still works, while N=5 does not: F(i,N) r[i] += ((a<<40) ^ (b<<20) ^ c) * s[i] % q[i] a,b,c are letters; s[i] and q[i] are primes; F(i,n) is for(int i = 0; i < (n); ++i) | WA 26 | Vasily Slesarev | 1286. Starship Travel | 18 Feb 2014 20:33 | 4 | WA 26 Vasily Slesarev 15 Jul 2009 19:40 Have somebody any things about test N 26? Thank you! I have founf a mistake. AC now. Re: WA 26 IgorKoval [PskovSU] 17 Sep 2013 03:08 I had WA 26 too. Stuped mistake. =) Was: ( v + f + i*p + k*q )%2==0 && ( -v + f + i*p - k*q )%2==0 && ( u + s - i*q - k*p )%2==0 && ( -u + s - i*q + k*p )%2==0 This get AC: ( v + f + i*(p/g) + k*(q/g) )%2==0 && ( -v + f + i*(p/g) - k*(q/g) )%2==0 && ( u + s - i*(q/g) - k*(p/g) )%2==0 && ( -u + s - i*(q/g) + k*(p/g) )%2==0 i guess || instead of && ? | No subject | bdm2505 | 2011. Long Statement | 17 Feb 2014 15:31 | 1 | Edited by author 18.02.2014 14:04 | Some clarifications that might help you | hopeless dreamer | 2000. Grand Theft Array V | 17 Feb 2014 04:38 | 2 | First of all, yes, the two players can be in the same cell, even at the beginning of the game. That only means that the first player that arrived there will take its value. Test: 5 1 2 3 4 5 1 1 Answer: 15 0 Test: 5 1 2 3 4 5 5 5 Answer: 15 0 Secondly, both players play optimally, so it is not a good idea to try and solve this problem using greedy methods. Furthermore, it is not even necessary to try and iterate each move. It suffices to find a technique that applies for each game and then it all reduces to computing a simple sum:) Good luck! | Runtime error | Grigorenko Vlad | 1011. Conductors | 17 Feb 2014 03:40 | 2 | Why I have Runtime error? I use C#. Code is here. using System; using System.Globalization; class EntryPoint { static void Main() { CultureInfo ci = new CultureInfo("en-US"); double p = Convert.ToDouble(Console.ReadLine(),ci); double q = Convert.ToDouble(Console.ReadLine(),ci); int x = 1; while (true) { if ((int)(q * x / 100) - (int)(p * x / 100) > 0) break; x++; } Console.WriteLine(x); } } Quote from problem description: "These numbers are separated by some spaces or "end of line" symbols" | If you have WA 11 or WA 17 | Mamuka Sakhelashvili [Freeuni] | 1227. Rally Championship | 16 Feb 2014 22:46 | 1 | try this test input: 4 3 12 1 2 5 1 3 4 3 4 4 output: YES | My AC code !!! | AYUBXON UBAYDULLAYEV (TUIT of IT) | 1588. Jamaica | 16 Feb 2014 19:51 | 3 | #include<iostream> #include<math.h> #include<algorithm> void quickSort(double x[],double y[],int left, int right) { int i = left, j = right; double tmp; double pivot = x[(left + right) / 2]; while (i <= j) { while (x[i] < pivot) i++; while (x[j] > pivot) j--; if (i <= j) { tmp = x[i]; x[i] = x[j]; x[j] = tmp; tmp = y[i]; y[i] = y[j]; y[j] = tmp; i++; j--; } }; if (left < j) quickSort(x,y,left, j); if (i < right) quickSort(x,y,i, right); } double dis(double x1,double y1,double x2,double y2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } using namespace std; int main() { double a[305][305],x[305],y[305],max,s1; int i,j,n,k; cin>>n; for(i=1;i<=n;i++)cin>>x[i]>>y[i]; quickSort(x,y,1,n); int left=1,right=1; for(i=2;i<=n;i++) { if(x[i]==x[i-1])right++; else { sort(y+left,y+right+1); right++; left=right; } } sort(y+left,y+right+1); for(i=1;i<n;i++) for(j=i+1;j<=n;j++) a[i][j]=dis(x[i],y[i],x[j],y[j]); for(i=1;i<n-1;i++) for(j=i+1;j<n;j++) { max=a[i][j]; bool f=0; for(k=j+1;k<=n;k++) if ((x[k]-x[i])*(y[i]-y[j])==(y[k]-y[i])*(x[i]-x[j])) { if (max<a[i][k]) max=a[i][k];else a[i][k]=0; if (max<a[j][k]) max=a[j][k];else a[j][k]=0; } if (max>a[i][j]) a[i][j]=0; } s1=0; for(i=1;i<n;i++) for(j=i+1;j<=n;j++)s1+=a[i][j]; s1=s1+0.4999999999; cout<<(long long)s1; system("pause"); return 0; } #include<cstdio> #include<cmath> int main() { double x[300],y[300]; double l[300][300],m,s=0; int n,k,i,j; scanf("%i",&n); for(i=0;i<n;i++) { scanf("%lf%lf",&x[i],&y[i]); j=i; while(j&&(x[j]<x[j-1]||(x[j]==x[j-1]&&y[j]<y[j-1]))) { x[j]=x[j]+x[j-1];x[j-1]=x[j]-x[j-1];x[j]=x[j]-x[j-1]; y[j]=y[j]+y[j-1];y[j-1]=y[j]-y[j-1];y[j]=y[j]-y[j-1]; j--; } } for(i=0;i<n-1;i++) for(j=0;j<n;j++) l[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])); for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(!l[i][j])continue; m=l[i][j]; for(k=j+1;k<n;k++) { if((x[i]-x[j])*(y[k]-y[j])==(x[k]-x[j])*(y[i]-y[j])) { (l[i][k]>m)?m=l[i][k]:l[i][k]=0; (l[j][k]>m)?m=l[j][k]:l[j][k]=0; } } if(l[i][j]<m)l[i][j]=0; s+=l[i][j]; } } printf("%.lf",s); return 0; } There is no need to reinvent the wheel, that is a half of the program devoted to sorting can be replaced with struct P{ double x,y; }; P p[n]; F(i,n) cin >> p[i].x >> p[i].y; sort(p, p+n, [](const P& a, const P& b){ return tie(a.x,a.y) < tie(b.x,b.y); }); To reduce number of possible typos, use macros, such as #define I(x) int x; cin >> x #define F(i,n) for(int i = 0; i < (n); ++i) #define FOR(i,a,b) for(int i = (a); i < (b); ++i) Finally, "do not post AC solutions" :-) | Java TLE Test #4 | Kunik | 1048. Superlong Sums | 16 Feb 2014 14:30 | 2 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; public class Solving { public StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws IOException { new Solving().run(); }
public int nextInt() throws IOException { in.nextToken(); return (int) in.nval; } public void run() throws IOException { int num = this.nextInt(); int[] arr = new int[num]; int a = 0; int b = 0; for (int iter1 = 0; iter1 < num; iter1++) { arr[iter1] = this.nextInt() + this.nextInt(); } StringBuilder str = new StringBuilder(); for (int iter2 = (arr.length - 1); iter2 > 0; iter2--) { a = arr[iter2]/10 + arr[iter2 - 1]%10; str.insert(0, (a%10 + b)); b = a/10; } if (b != 0) { str.insert(0, b); } str.append(arr[arr.length - 1]%10); this.out(str.toString()); } public void out(String str) { out.println(str); out.flush(); } } I don't know how make this faster. Help me please. Edited by author 16.02.2014 03:25 How do you think what is the complexity of StringBuilder.insert() method? | I think it an excellent math problem. | Koala | 1204. Idempotents | 16 Feb 2014 03:04 | 7 | It could be more interesting if n were not only p*q but any number <= 1000000000. Well I think this way it's somehow more mathematical, cause you can predict some properties of the equations answer. If I am not mistaken, than solving this problem is as "hard" as factoring n (having 3 or 4th solution you can obtain factorisation of n). Was this problem inspired by RSA? | Факапы не написанные в условии | Sinigami17 | 1083. Factorials!!! | 16 Feb 2014 02:36 | 2 | 1) множитель не может быть отрицательным 2) умножать надо не по количеству восклицательных знаков а пока i*k < n 3) если ( n - i*k ) равно n % k или ( n - i*k ) равно k значит мы посчитали факториал ( то есть надо больше ничего с числом не делать ) 4) n и k от 1 до 20 5) составители задачи тупые мудаки I would say the same ("tupoi mudak" (*)) about the author of the post. Problem statement is more than clear: "n!!…! = n(n−k)(n−2k)…(n mod k)", "X mod Y — a remainder after division of X by Y", then even example is given: "10 mod 3 = 1". If after all this you couldn't derive that "1) множитель не может быть отрицательным" - then you're really (*) "3) если ( n - i*k ) равно n % k или ( n - i*k ) равно k значит мы посчитали факториал ( то есть надо больше ничего с числом не делать )" - just copy from the problem statement "4) n и k от 1 до 20" - just wrong (n <= 10, as, again, given in the statement) | Strange test (RTE 3) | Alex Danilyuk [SESC USU Dandelion] KTC | 1211. Collective Guarantee | 15 Feb 2014 19:48 | 2 | This is the fragment of my program: scanf("%d", &n); for (int i = 0; i < n; i++) { int p; scanf("%d", &p); p--; if (p >= n) throw; If I remove throw, I'll have WA 3. So children can say absolutely incorrect information? No, all tests are correct. There is some bug in your code, it is reason of WA/RT 3 | Some tests | RybKMU | 1374. Misere | 14 Feb 2014 15:35 | 2 | Here: 7S 9S KS 7C 9C QC 7D 8D 9D 7H QS 10S AC KC 8C KD 10D AH 9H 8H AS JS 8S JC 10C AD QD JD JH 10H 3 ;( 7S 10S 7C 8C 9C JC 7D 9D 7H 8H QS JS 8S KC QC 8C AD 8D QH 10H AS KS 9S 10C QD JD 10D KH JH 9H 3 ;( 7S 10S 7C 8C 9C JC 7D 9D 7H 8H QS JS 8S QC 8C AD 8D QH 10H KH AS KS 9S KC 10C QD JD 10D JH 9H 3 ;) 7S 7C 7D 10D JD QD KD 7H 9H JH 10S 9S KC 9C 8C AD 9D 8D AH 8H AS KS QS 8S AC JC 10C KH QH 10H 3 ;( 7S 7C 7D 10D JD QD KD 7H 9H JH 10S 9S KC 9C 8C 9D 8D AH 8H KH AS KS QS 8S AC JC 10C AD QH 10H 3 ;( 7S 7C 7D 10D JD QD KD 7H 9H JH 8S 9S 10C 9C 8C AD 9D 8D 8H 10H AS KS QS 10S AC KC JC AH KH QH 3 ;) 7S 7C 7D 9D JD KD 7H 10H JH QH AS AC KC QC JC 9C AD QD 10D KH KS 10S 9S 8S 10C 8C 8D AH 9H 8H 2 ;( 9S 10S JS 9C 10C JC 9D 10D JD JH 8S 7S 8C 7C 8D 7D 7H 8H 9H 10H AS KS QS AC KC QC AD KD QD QH 2 ;) AC 7D KD QH 8H 8C 8S 9C QC 10C KH 7H JH 7C 9H JS QD 8D 7S JD 10H KC AS AH QS JC 10D KS AD 10S 1 ;) 7C AH QC KC KD 9C 9H 8C 10C JH QS JC 9D 10H KH JD JS AC 8S AS 10D 7H KS 10S AD 7D 8H QH 8D QD 1 ;( 8C 10S 9D 7S KD QC 9C KS JC 8S 8H JD 7D QH 10H 10D 8D 10C AH JS KC QD 9S JH QS AS KH 9H 7H AC 3 ;( at least 2 tests are incorrect: 2nd & 3rd contains double 8C | TL 11, help please | KOTMAKRUS | 1998. The old Padawan | 14 Feb 2014 00:44 | 1 | Edited by author 14.02.2014 01:31 Edited by author 14.02.2014 01:31 | How to solve this problem(1158)? It's too hard.... | Sa Lang Hae | 1158. Censored! | 14 Feb 2014 00:35 | 10 | I have been working on it for a week.... Why extreme difficulty? My DP is about 30 lines. Idea is very simple. But it's hard to discover as well :) I mean no true DP solution is really large, but this very DP is rather difficult to find and understand. would you please tell me your method? I think only a big-number code will use more than 30 lines... ALGO IS HERE: 1. Remove all words which contain some other word as a substring. They do not affect anything, but make further things more difficult. 2. Build characters tree from forbidden words. E.g. for set "aabc, abd, bcd" it will be like that: root(a(a(b(c)),b(d)),b(c(d))) positions in this tree will represent history (recent placed letters) and its size will be <= 100 (total amount of letters in all forbidden words) A path from root to node is safe if it does not end in a leaf (otherwise you're in jail for 10 years). Any sub-paths of a safe path are also safe because we removed all words which could lead to such paths. So, we have a good test for path safety - it shouldn't be a leaf, and that's enough. While we place letters, we are allowed to make only safe steps - we can't step into a leaf. If we attempt to perform a step outside of the tree, we should apply 1st postfix of history to that tree to find where will we get after forgetting that least recent placed letter. For example, if the string 'aabce' falls out from the tree after 'aab' (i.e. there is no forbidden word starting with 'aabc'), then we will search for 'abce' (1st postfix of 'aabce') in the same manner, recursively. All this information can be precalculated (which state leads where after adding some particular letter). It's like prebuilding automaton for multi-substring search and then calculate number of programs which do not lead to terminal states. This gave me AC in 0.031 sec and final understanding of KMP which I used blindly before :) Edited by author 05.08.2008 04:24 The limits are not very strict. I did not perform precalculation and did not build automata. | хотя бы шесть различных слов длины n | Sinigami17 | 2011. Long Statement | 13 Feb 2014 20:28 | 1 | Ребята будьте внимательный когда читаете условия. Я потратил пол часа пока понял что нужно составить не менее 6 а не не менее n слов... | WA8. What the f??k :) | Evgeniy++ | 1795. Husband in a Shop | 13 Feb 2014 18:49 | 8 | Hello gentlemen! Who can explain why I get WA8? Are there any test data available to anyone? 1 10 of anawa 2 10 of anawa 1 of anawa answer = 2 not 3 Edited by author 24.10.2010 04:07 I've got this answer, but WA8 too. Try this test 1 2 of vodka 1 3 of vodka answer 1 Yes, it is ;) Edited by author 22.07.2012 20:26 Edited by author 22.07.2012 20:26 Edited by author 22.07.2012 20:31 2 100 of vodka 1 of matryoshka 3 100 of vodka 1 of vodka 1 of matryoshka | What is the test 2? | Anam | 1880. Psych Up's Eigenvalues | 13 Feb 2014 17:05 | 1 | wrong answer, but I do't know why! help, please #include<iostream> using std::cout; using std::cin; using std:: endl; int main(){ int res = 0; int n1, n2, n3; cin >> n1; unsigned *arr1 = new unsigned[n1];
unsigned temp[100]; for(int i = 0; i < n1; ++i){ cin >> arr1[i]; } cin >> n2; unsigned *arr2 = new unsigned[n2]; for(int i = 0; i < n2; ++i){ cin >> arr2[i]; } cin >> n3; unsigned *arr3 = new unsigned[n3]; for(int i = 0; i < n3; ++i){ cin >> arr3[i]; } int sum = 0; for(int i = 0; i < n1; i++){ for(int j = 0; j < n2; ++j){ if(arr2[j] == arr1[i]) temp[i]= arr2[j]; sum++; } } int sum1 = 0; for(int i = 0; i < sum; i++){ for(int j = 0; j < n3; ++j){ if(arr3[j] == temp[i]) sum1++; } } cout << sum1 << endl; delete[]arr1; delete[]arr2; delete[]arr3; system("PAUSE"); return 0; } | Something is wrong with Check Program | Delyan | 1625. Hankel Matrix | 13 Feb 2014 16:45 | 9 | I make matrices from the sequence of Catalan numbers 1,2,5,14,42,132,429,1430,4862,... Such matrices satisfy all criterion: 1)All numbers are positive integers 2) Determinants of all matrices are equal to 1 But I get WA2 I got AC using your method with first submission. Edited by author 10.08.2009 18:08 I use your method, but I got wa6. :( please help me. Edited by author 11.11.2009 21:43 Wow, its great, but how did you get to Catalan's numbers? please said me, what answer when n=20? thanks burn in hell with you spoiler | O(NlogN) C++ soluton | Maxim | 1021. Sacrament of the Sum | 13 Feb 2014 03:02 | 1 | /* * File: main.cpp * Author: Maxim Cherchuk <maxim.cherchuk@gmail.com> * * Created on 12 Февраль 2014 г., 23:36 */ #include <iostream> #include <algorithm> using namespace std; /* * */ const int MAXN = 50000, MAX = 10000; int a[MAXN], b[MAXN]; int n, k, m; int main(int argc, char** argv) { ios_base::sync_with_stdio(0); cin >> n; for(int i = 0; i < n; ++i) { cin >> a[i]; } cin >> k; for(int i = 0; i < k; ++i) { cin >> b[i]; } sort(a, a+n); sort(b, b+k); for(int i = 0; i < n; ++i) { const int cur = a[i]; int l = 0; int r = k; while(r-l > 1) { // binary search m = (l+r)>>1; if(cur+b[m] > MAX) r = m; else l = m; } if(cur + b[l] == MAX) { cout << "YES"; return 0; } } cout << "NO"; } |
|
|