Common Boardwhen you calculate q you must use (res-(1e-7))*q/100.0; is in your example abababa right answer aba or only a??? because a is 4 and aba is 3. test №1: "abababa" ; correct answer: "a" test №2: "abcde" ; correct answer: "abcde" For "abcde" correct: a, b, c, d, e, ab, bc, cd, de, abc, bcd, cde, abcd, bcde, abcde Edited by author 15.11.2010 10:11 why correct answer is "a" , in my opinion answer must be "ababa" cause prefix is like that 0 0 1 2 3 4 5 "choosing" -> "chosen" "divided" -> "divisible" "satisfied" -> "satisfying the" "is really completely defines" -> "completely defines" These aren't just typos, they impede the understanding. 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. 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. 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). 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 What is algorithm? What formulas, theorems, equations and hints must I use? Is here some adia? =) 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. 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. =) 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 Несмотря на то, что задача просто решеется с помощью 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 Pff, too easy with just map<string, bool>. 0,937s is enough. 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! 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 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 =============== #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. Edited by author 11.02.2013 22:27 Edited by author 11.02.2013 22:27 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!-) 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. 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 Thank you very much! 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? 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 |
|