Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Question! | uzairBaig | 1350. Canteen | 14 Feb 2013 16:54 | 3 | I cannot understand the problem. The question is phrased pOorly ! If there is anyone, who can tell me, the question clearly, I am ready to phrase it in a better way. Use this statements: 1) There are N different food stuffs in the menu but not all of them are at the distribution. 2) The food is cooked from M different food stuffs. 3) The first student eats and he is not poisoned. 4) The first block describes the food stuffs dangerous for the first student, 5) the next K blocks — for the rest ones. And try to think a little. It's not very hard. ;) Combination formula can help. | | Can anybody interpret the promblem for me? thx | ppchain | 1716. Alternative Solution | 13 Feb 2013 18:08 | 2 | The "YES" come from two ways:1) when there is not have answer.txt;2) when answer.txt contain it.but i can't figure out this related to pass test! pass test should be the output.txt's content is same to answer.txt. how to explain the hint's explanation? We answer "YES" if "YES" was right answer for previous test. | | I do not know how to solve it in C++. | Martin | 1716. Alternative Solution | 13 Feb 2013 18:06 | 3 | No matter when I used double or long double, my code still got TLE. Opt[Now][j][0] = Opt[Pre][j][0] + Opt[Pre][j][1] + Opt[Pre][j][3]; Opt[Now][j][1] = Opt[Pre][j - 1][0] + Opt[Pre][j - 1][2] + Opt[Pre][j - 1][1]; Opt[Now][j][2] = Opt[Pre][j][2] + Opt[Pre][j][3]; Opt[Now][j][3] = Opt[Pre][j - 1][2] + Opt[Pre][j - 1][3]; I had to write a Pascal code using extended and got AC. Could anyone tell me how to AC in C++? I know solution which can be written on all allowable languages. I suppose, this solution won't get TLE. Becouse it is O(1). I know solution which can be written on all allowable languages. I suppose, this solution won't get TLE. Becouse it is O(1). | | cub(N) Solution | aybek | 1297. Palindrome | 13 Feb 2013 14:42 | 1 | I don't know why this solution is correct, but it got accepted. I thought that this solution will get TL. Author of problem: easy tests? Who couldn't find solution try to understand this code: #include<map> #include<cmath> #include<ctime> #include<vector> #include<cstdio> #include<string> #include<cstring> #include<cstdlib> #include<iostream> #include<string.h> //#include<windows.h> #include<algorithm> #define y1 abcde #define sqr(x) ((x)*(x)) #define INF 20000000000000000 using namespace std; string s; int i,n,ans,j,l,r;
bool check(int l,int r) { for(int i = 0; i < (r - l + 1) / 2; i++) if (s[l+i] != s[r-i]) return false; return true; } int main() { //srand(GetTickCount()); #ifndef ONLINE_JUDGE freopen("a.in","r",stdin); freopen("a.out","w",stdout); #endif cin>>s; n = s.size(); i++; s = '#' + s; for(i = 1; i <= n; i++) for(j = i; j <= n; j++) { if (check(i,j)) if (j - i + 1 > ans) ans = j-i+1, l = i, r = j; } for(i = l; i <= r; i++) cout<<s[i]; return 0; } Edited by author 13.02.2013 14:44 Edited by author 13.02.2013 14:45 | | Test #2 | George | 1910. Titan Ruins: Hidden Entrance | 13 Feb 2013 00:29 | 1 | | | Algo. | IgorKoval(from Pskov) | 1647. Divide an Island! | 12 Feb 2013 23:33 | 5 | Algo. IgorKoval(from Pskov) 9 Apr 2012 02:25 What is algorithm? What formulas, theorems, equations and hints must I use? Re: Algo. IgorKoval(from Pskov) 15 May 2012 22:53 Suppose that answer is XY, where point X lies on CA and Y lies on CB. Then let CX = x, CY = y. Now you have two equations: x + y = P/2, x * y = CA * CB / 2 (P is perimeter). The rest of solution is straightforward. Re: Algo. IgorKoval(from Pskov) 16 May 2012 23:59 Thank you very much! Very good adia! P.S.: How get x * y = CA * CB / 2 ? Just simple: 2 * SQUARE_CXY == SQUARE_ABX 2 * 0.5 * x * y * sinXCY == 0.5 * CA * CB * sinXCY x * y == 0.5 * CA * CB x * y = CA * CB / 2 I think about it several minute. =) | | WHY "Runtime error" ????!!!!!! | Iuhenio{PSU} | 1821. Biathlon | 12 Feb 2013 23:06 | 1 | using System; class Program { static void Main() { int N = int.Parse(Console.ReadLine()); if (N > 0 && N <= 100) { string[,] IData = new string[N, 3]; string[] buf = new string[2]; for (int i = 0; i < N; i++) { buf = Console.ReadLine().Split(' '); IData[i, 0] = buf[0]; IData[i, 1] = buf[1]; IData[i, 2] = Convert.ToString(i + 1); } String[] Win = new string[N]; string[] Lider = new string[2]; Lider = IData[0, 1].Split(':'); int k = 0; for (int i = 1; i < N+1; i++) { buf = IData[i, 1].Split(':'); if (int.Parse(Lider[0]) > int.Parse(buf[0])) { if (i == 1 && (60 - double.Parse(buf[1].Replace(".", ",")) + double.Parse(Lider[1].Replace(".", ",")) < 30)) { Win[k] = IData[0,0]; k++; } Win[k] = IData[i, 0]; k++; Lider = IData[i, 1].Split(':'); } if (int.Parse(Lider[0]) == int.Parse(buf[0])) { if (double.Parse(Lider[1].Replace(".", ",")) > double.Parse(buf[1].Replace(".", ","))) { double tmp = double.Parse(Lider[1].Replace(".", ",")) - double.Parse(buf[1].Replace(".", ",")); if (i == 1 && tmp < 30) { Win[k] = IData[0, 0]; k++; } Win[k] = IData[i, 0]; k++; Lider = IData[i, 1].Split(':'); } } if (int.Parse(Lider[0]) < int.Parse(buf[0])) { Win[k] = IData[0, 0]; k++; } } Console.WriteLine(k); Array.Sort(Win); for (int i = 0; i < k; i++) { Console.WriteLine(Win[i]); } } } } Edited by author 12.02.2013 23:07 | | Идея | ibra (TNU) | 1414. Astronomical Database | 12 Feb 2013 21:25 | 2 | Идея ibra (TNU) 11 Jan 2012 15:04 Несмотря на то, что задача просто решеется с помощью std::set, я написал сжатый бор. Первый раз писать немного сложно, но весело. А теперь ещё и просто. а если в вершинах бора хранить не map<string, node*> а попроще map<pair<int, int>, node*>, то я думаю результат был бы более впечатлительным P.S. решайте сжатым бором Accepted 0.312 2 904 КБ Edited by author 11.01.2012 15:06 Re: Идея Andrew Sboev [USU] 12 Feb 2013 21:25 Pff, too easy with just map<string, bool>. 0,937s is enough. | | puzzle | lian lian | 1057. Amount of Degrees | 12 Feb 2013 20:54 | 5 | puzzle lian lian 3 Sep 2008 10:23 my program output result: 1 1000000000 3 13 -> 84 1 1 2 2 ---> 0 1 100 2 4 ->6 1 300 4 8 ->0 1 400 4 2 ->111 1 2147483647 13 3 --> 77520 1 2147483647 20 2 --> 84672315 1 3 1 2 --> 2 is right? if full right , but i alway wa #7, who can give much testdata to me ? Edited by author 03.09.2008 10:39 Edited by author 05.09.2008 02:08 all your answers are correct. tests you asked: 1 8 2 3 --> 1 1 900 2 10 --> 3 1 123456789 4 10 --> 126 1 999999999 8 10 --> 9 Thanks for your test,I'v got AC this problem! all your answers are correct. tests you asked: 1 8 2 3 --> 1 1 900 2 10 --> 3 1 123456789 4 10 --> 126 1 999999999 8 10 --> 9 Thanks from me too for the excellent testset! | | no impossible case???? | HM2P33 | 1106. Two Teams | 11 Feb 2013 21:51 | 2 | i've got AC but i omitted the case "impossible" (ie print "0"). it has always solution? >>Well, there is no solution, for example, if someone has no friends. UPD: Yes, I didn't read it correctly and I think there are really no impossible cases. Edited by author 11.02.2013 21:53 | | What is the answer for the such test case | Megakrit | 1837. Isenbaev's Number | 11 Feb 2013 21:46 | 2 | e.g. the input is (if I'm not wrong it's valid input): 3 Isenbaev A B A A A B B B What is the correct answer? My AC Solution's output: =============== A 1 B 1 Isenbaev 0 =============== | | Access violation N 3 | Lord_F | 1837. Isenbaev's Number | 11 Feb 2013 21:45 | 2 | #include <cstdio> #include <deque> #include <queue> #include <vector> #include <string> #include <set> #include <stack> #include <algorithm> #include <cmath> #include <iostream> #include <fstream> #include <climits> #include <cfloat> #include <map> #include <cstring> #define FOR(i,s,e) for(long i = s; i < e; ++i) #define FORD(i,e,s) for(long i =e-1; i>=s; --i) #define read(a) scanf("%ld",&a); #define readf(a) scanf("%lf",&a); #define read2(a,b) scanf("%ld %ld",&a,&b) #define read2f(a,b) scanf("%lf %lf",&a,&b) #define write(a) printf("%ld ",a); #define writef(a) printf("%lf ",a); #define write2(a,b) printf("%ld %ld ",a,b) #define write2f(a,b) printf("%lf %lf ",a,b) #define writeln(a) printf("%ld\n",a); #define writelnf(a) printf("%lf\n",a); #define writeln2(a,b) printf("%ld %ld\n",a,b) #define writeln2f(a,b) printf("%lf %lf\n",a,b) #define nln printf("\n") #define elif else if #define MOD 1000007 #define EPS 1e-9 #define INF 2117117117 #define mp(a,b) make_pair(a,b) #define dist(x1,y1,x2,y2) sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) #define pb(a) push_back(a) using namespace std; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); long n; read(n); scanf("\n"); map<string, long> m; vector<long> g[318]; long c=0; string s1,s2,s3; FOR(i,0,n) { getline(cin,s1,' '); if (m.find(s1)==m.end()) m.insert(mp(s1,c++)); getline(cin,s2,' '); if (m.find(s2)==m.end()) m.insert(mp(s2,c++)); getline(cin,s3,'\n'); if (m.find(s3)==m.end()) m.insert(mp(s3,c++)); long a=m.find(s1)->second,b=m.find(s2)->second,c=m.find(s3)->second; g[a].pb(b); g[a].pb(c); g[b].pb(a); g[b].pb(c); g[c].pb(a); g[c].pb(b); } long d[318]; FOR(i,0,c) d[i]=-1; long s = m.find("Isenbaev")->second; d[s]=0; queue<long> q; q.push(s); long v; while (!q.empty()) { v=q.front(); q.pop(); FOR(i,0,g[v].size()) { if (d[g[v][i]]==-1) { d[g[v][i]]=d[v]+1; q.push(g[v][i]); } } } map<string, long>::iterator it; for( it = m.begin(); it != m.end(); ++it) { printf("%s ",it->first.c_str()); if (d[it->second]==-1) printf("undefined"); else write(d[it->second]); nln; } return 0; } Why?? Oh, I see now, there is no Isenbaev in the 3rd test, so all people are undefined. | | WHY WA5 ? | Iuhenio{PSU} | 1581. Teamwork | 11 Feb 2013 21:43 | 1 | Edited by author 11.02.2013 22:27 Edited by author 11.02.2013 22:27 | | To Admins! | kami_botanik | 1787. Turn for MEGA | 11 Feb 2013 21:40 | 1 | There are wrote Runtime error (access violation), and number of test 1. What's that meen? Sorry if I wrong! But I'm not exactly understand, what in this code is Wrong!? Fist test I suppose is 5 3,6 7 2 and 5 3,20 0 0 and my programm show's 0 and 5, exactly like in example. Beforehand Thank's and ne "obisuyte" for my english!-) | | WA5... | Phil | 1206. Sum of Digits of the Sum of Numbers | 11 Feb 2013 19:48 | 2 | I used long arithmetics and calculated "36*pow(55,k-1);". But I have WA5. Please, say why or give that test... Maybe you write wrong long arithmetics. I think you forgot leading zeroes. I had the same mistake. Use this test: 9 3014421764062500 Sorry for my poor English. | | WA test 7 | Karpov Alexandr | 1922. Superhero Team | 11 Feb 2013 05:49 | 8 | What's this test? Edited by author 28.10.2012 13:07 Try this test: 5 1 1 1 1 1 Answer is 1 5 1 2 3 4 5 Numbers order in the last(after 5) doesn't metter but if we add to team 1 2 3 4 hero#5 this team will be effective? All teams that satisfy each member's demands are effective, the key to this problem is understanding the definition of "reliable." It took me several readings of the problem statement to get this clear. Excuse me. I can't understand you. Can you answer my question? in test 5 1 1 1 1 1 team with heroes 1, 2, 3 and 4 is reliable? It appears the wording for the problem has changed. This was a badly worded problem to begin with, but now it is *incorrectly* worded! The original wording was something like: "an effective team is also reliable if there exists no superhero such that adding the superhero to the team results in an effective team." Basically, a "reliable" team is one that cannot be added on to (by exactly one superhero) to make another effective team. So no, in the case "5 / 1 / 1 / 1 / 1 / 1" , "1 2 3 4" is not reliable because there exists a superhero such that adding it on to the team makes another effective team. Edited by author 31.10.2012 03:05 On this test: 5 1 1 1 1 1 My program gets Answer is 1 5 1 2 3 4 5 but I am still getting WA7. yet have any thoughts on this? | | Time limit exceeded | david | 1209. 1, 10, 100, 1000... | 11 Feb 2013 02:49 | 2 | What's wrong? var n,p,k,i:longint; m:array [1..65535] of longint; begin readln(n); p:=1; k:=0; for i:=1 to n do readln(m[i]); for i:=1 to n do begin while m[i]>p do begin p:=p+k; k:=k+1; end; if p=m[i] then write(1,' ') else write(0,' '); p:=1; k:=0; end; end. you shold use maths method, maths formula | | Who can help me with WA#3 ? | Iosif inf-10 | 1220. Stacks | 10 Feb 2013 18:10 | 1 | #include <stdio.h> #define MaxN 100000+252 #define MaxPop MaxN/2+1 struct pointer { int s; char o; }; struct pointer GetPointer(int i) { struct pointer p; p.s=i/250; p.o=i % 250; return p;
} struct Stack { int V; struct pointer pred; }; int GetAdress(struct pointer p) { return p.s*250+p.o; } int A[1001]; int MP; struct Stack B[MaxN]; int Pop(int S) { int E; E=B[A[S]].V; A[S]=GetAdress(B[A[S]].pred); return E; } int Push(int S, int E) { int i=A[S]; MP++; B[MP].V=E; B[MP].pred=GetPointer(i); A[S]=MP; return 0; } int main() {
int N,i,j,E,k; int S; char command[10]; scanf("%d",&N);
MP=0; B[MP].V=0; B[MP].pred=GetPointer(0); for (i=1;i<1000;i++) A[i]=0; k=0; for (i=1;i<=N;i++) {
scanf("%s",command); if (command[1] == 'U'){ scanf("%d %d",&S,&E); Push(S,E); } else { scanf("%d",&S); k++; printf("%d\n",Pop(S)); } }
return 0; } | | 1220. Stacks Who can help me with WA#3 ? | Iosif inf-10 | | 10 Feb 2013 18:09 | 1 | Here is my code #include <stdio.h> #define MaxN 100000+252 #define MaxPop MaxN/2+1 struct pointer { int s; char o; }; struct pointer GetPointer(int i) { struct pointer p; p.s=i/250; p.o=i % 250; return p;
} struct Stack { int V; struct pointer pred; }; int GetAdress(struct pointer p) { return p.s*250+p.o; } int A[1001]; int MP; struct Stack B[MaxN]; int Pop(int S) { int E; E=B[A[S]].V; A[S]=GetAdress(B[A[S]].pred); return E; } int Push(int S, int E) { int i=A[S]; MP++; B[MP].V=E; B[MP].pred=GetPointer(i); A[S]=MP; return 0; } int main() {
int N,i,j,E,k; int S; char command[10]; scanf("%d",&N);
MP=0; B[MP].V=0; B[MP].pred=GetPointer(0); for (i=1;i<1000;i++) A[i]=0; k=0; for (i=1;i<=N;i++) {
scanf("%s",command); if (command[1] == 'U'){ scanf("%d %d",&S,&E); Push(S,E); } else { scanf("%d",&S); k++; printf("%d\n",Pop(S)); } }
return 0; } Edited by author 10.02.2013 18:10 | | WA6 | Shree | 1823. Ideal Gas | 10 Feb 2013 04:21 | 1 | WA6 Shree 10 Feb 2013 04:21 What is test 6? I am stuck at it for a very long time! |
|
|