Common BoardCan someone give me test #18??? Or give me some tests and answers??? For: 75000000000000000 50000000000000000 25000000000000000 answer is 2 (1 ≤ x1, x2, x3 ≤ 10^18) Try to use int64 Thanks, but i have already use int64/ but i dont know where's my error... :( I have submitted it more than one times with int64, but again and again I got WA on test19, however, same source code in Java using BigInteger was accepted at once. 45 1 12 You can have problems with sorting your array it was helped me. Good luck, bro! Edited by author 13.12.2018 21:43 Edited by author 13.12.2018 21:43 I didn't find a mistake in my program. And what is the test #19? I'am confused( 45 1 12 it was helped me. Good luck, bro! tovars,prices,recomendations= [],[],[] for i in range(6): name = input() tovar = input() price = int(input()) if tovar in tovars: if prices[tovars.index(tovar)] > price: prices[tovars.index(tovar)] = price recomendations[tovars.index(tovar)] +=1 else: tovars.append(tovar) prices.append(price) recomendations.append(1) if recomendations.count(max(recomendations)) == 1: print(tovars[recomendations.index(max(recomendations))]) else: ans = [] ans1 = [] l = len(tovars) mm = max(recomendations) for i in range(l): if recomendations[i] == mm: ans.append(tovars[i]) ans1.append(prices[i]) print(ans[ans1.index(min(ans1))]) Could you please add Common Lisp as a language? SBCL is the most popular, and most performant, implementation of Common Lisp, and has been for some time (forked from CMUCL nearly 20 years ago)! It is also mostly maintained by Stas Boukarev. It has static typing, and it would be a beautiful language to solve Timus problems in. Common Lisp has been around for a very long time and its ANSI Standard has been the same for quite a number of years, so it is possible that there would not need to be many updates after it is added once. Adding the SBCL implementation as a supported language would be greatly appreciated by me and the Common Lisp community to be able to solve the amazing problems on this website with this very performant meta programming language. While attempting to get SBCL added, this repo could be used for reference -- https://github.com/optimisticlisper I really hope you will consider it. #include<stdio.h> #include<math.h> int main() { int n;
printf("%d\n",scanf("%d",&n)*n*scanf("%d",&n)*n*scanf("%d",&n)*n*2); } you write so complex, the answer is N*A*B*2 why so complex man!! Should it work at all? Isn't it unspecified behavior - n is modified 3 times in the same expression? Brother, you should solve it step by step!Don't do all things in printf function.In this way u can easily find you bug! You can follow this method n*a*b*2 At first,I got wa on test1,like many other authors.But later,I found it! All in one sentence,test the data below: 1 inputon Hello, The answer is YES and my program out puts YES, but I get WA1. Can you please help me what I am doing wrong. It passes all of my tests but gets wa 1. I'm confused too, maybe there are some design errors, like 'Yes' or 'yes'when you have to use "YES\n" I have the same problem and the reason of problem was: character '\r' at the end of test inputs string (at my PC i use Linux and there is no such problem). Then I start to check input for '\r' character and this code was accepted! it's good test. Thank you. Create struct: struct Animal which has: - ID // ID of hero - name // name of animal (char *) (cin.getline) (cin.ignore()) - strength(int) // power of animal - frequency // number of hits in one iteration - HP // amount of life Your task is to show animal which won most rounds in the game. Input: n (how many animals) [2 <= n <= 10] n-times: ID name strength frequency goals HP goals Output: winner with amount of victory. Example: Input: 10 1 Lion John 30 2 100 // (0 1 0 0 1 0 1 0 0) 3 victory 2 Hen Rebecca 60 1 200 // (1 1 1 0 1 0 1 0 1) 6 victory 3 Tiger Alex 40 2 100 // (1 0 0 0 1 0 1 0 1) 4 victory 4 Buffalo James 40 3 100 // (1 1 1 0 1 0 1 0 1) 6 victory 5 Elephant Jack 50 1 300 // (1 1 1 1 1 0 1 0 1) 7 victory 6 Rhino Michael 30 1 200 // (1 0 0 0 0 0 1 0 0) 2 victory 7 Snake Oz 50 2 400 // (1 1 1 1 1 1 1 1 1) 9 victory 8 Cow Bettie 40 1 100 // (0 0 0 0 0 0 0 0 0) 0 victory 9 Crocodile Nick 20 3 500 // (1 1 1 1 1 1 0 1 1) 8 victory 10 Bear Drake 40 2 150 // (1 1 1 1 0 1 0 1 0) 6 victory Output : 7 Snake Oz 50 2 400 9 victory use "long double" and to avoid rounding when you print the result, use cout << fixed <<setprecision(0)<< result << endl; Can you explain us why long double accepted and why double get WA13 ? Edited by author 21.01.2019 19:40 If it is a real tree, why after N lines, describing conviviality ratings of employees, we have not simply (N - 1) lines, describing supervisor relations? Does such input format mean that some employees may have more than one supervisors? Edited by author 21.06.2012 18:08 Input contains only one tree (not forest) so don't worry about this ! Why do I memory limit exceeded even if I have use pointer? Here is my code: const mn=6000; inf=-100000000; type rec=record father:integer; num:integer; child:array[1..mn]of ^integer; end; var value:array[1..mn]of ^integer; f:array[1..mn,1..2]of ^longint; t:array[1..mn]of ^rec; n,i,a,b,root:integer; ans:longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; function dp(root,lab:integer):longint; var i:integer; begin if root=0 then exit(0); if f[root,lab]^>inf then exit(f[root,lab]^); if lab=1 then begin f[root,lab]^:=value[root]^; for i:=1 to t[root]^.num do inc(f[root,1]^,dp(t[root]^.child[i]^,2)); end else begin f[root,lab]^:=0; for i:=1 to t[root]^.num do inc(f[root,2]^,max(dp(t[root]^.child[i]^,1),dp(t[root]^.child[i]^,2))); end; exit(f[root,lab]^); end; begin readln(n); for i:=1 to n do begin new(value[i]); new(t[i]); new(f[i,1]); new(f[i,2]); readln(value[i]^); end; while not eof do begin readln(a,b); if(a=0)and(b=0)then break; t[a]^.father:=b; inc(t[b]^.num); new(t[b]^.child[t[b]^.num]); t[b]^.child[t[b]^.num]^:=a; end; for i:=1 to n do if t[i]^.father=0 then begin root:=i; break; end; for i:=1 to n do begin f[i,1]^:=inf; f[i,2]^:=inf; end; ans:=max(dp(root,1),dp(root,2)); writeln(ans); end. Who can HELP me? Edited by author 05.04.2010 16:57 because u r using much memory.. run it on ideone.. u will come to know This problem is too simple than you think :) Edited by author 10.12.2018 17:39 Some test cases that helped me: 6 4 001000 100001 000100 000010 010000 100100 100000 111000 100000 ans: 111111 6 4 010000 100000 001000 100001 100000 111000 000100 000001 100000 ans: 111001 6 4 100000 111000 010000 100000 001000 100001 000100 000001 000000 ans: 000000 6 4 111100 111000 111110 100000 000000 100001 111111 000001 010100 ans: 110101 6 4 111000 101000 111100 111000 111110 100000 111111 000001 011100 ans: 011100 6 0 010100 ans: 010100 6 1 5 2 6 3 7 4 8 5 9 6 10 WHY answer is: 2 1 5 5 9 I think [2;6] and [3;7] have common interior point such as 3, 4, 5, 6. What's the meaning of "Land fragments that are adjacent to the map's border are not considered as islands." ??? I can hardly understand it ! in the Example input, There is two island adjacent to the map's border(the north-east corner and the south-west corner) . but the answer is 3 !!! can anyone help me ? In the first sample I checked the sacred islands' territory as '*': ........# .*******. .*.....*. .*.*.*.*. .*.....*. .*******. #........ So, there are 3 sacred islands. The land fragments in the corners of the map are not the islands, because they are adjacent to the map's border. but those islands are not in the same sea /\/\/ \/\/\ /\*\/ \/\/\ /\/\/ ans: FAIL \/\/\ \/\/* //\// \\\// \/\\/ ans: U2 /\/// \/\\/ /\\*\ \/\// /\/\\ ans: WIN \\/// //\// *\\\\ \\\/\ //\// ans: U1 \/\// \/\\\ ///// *\\\\ \//\/ ans: WIN so this is a NP complete problem ,how can it be solved with 1000 range.. I don't know Can anybody tell me test 5,i am getting WA.I have tried my code on many random cases and it works fine. Code:- #include<bits/stdc++.h> #define PB push_back #define MP make_pair #define F first #define S second #define SZ(a) (int)(a.size()) #define SET(a,b) memset(a,b,sizeof(a)) #define LET(x,a) __typeof(a) x(a) #define TR(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++) #define loop(i,a,b) for(int i=a;i<b;i++) #define si(n) scanf("%d",&n) #define sll(n) scanf("%lld",&n) #define sortv(a) sort(a.begin(),a.end()) #define all(a) a.begin(),a.end() #define bitcount(n) __builtin_popcount(n) #define DRT() int t; cin>>t; while(t--) #define TRACE #ifdef TRACE #define trace1(x) cerr << #x << ": " << x << endl; #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl; #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl; #define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl; #define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl; #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl; #else #define trace1(x) #define trace2(x, y) #define trace3(x, y, z) #define trace4(a, b, c, d) #define trace5(a, b, c, d, e) #define trace6(a, b, c, d, e, f) #endif using namespace std; typedef long long int lli; typedef pair<int,int> ii; typedef vector<int> vi; typedef vector< vi > vvi; typedef vector< ii > vii; lli modpow(lli a,lli n,lli temp){lli res=1,y=a;while(n>0){if(n&1)res=(res*y)%temp;y=(y*y)%temp;n/=2;}return res%temp;} //***********************************END OF TEMPLATE********************************************************************* const int MAX = 50005,MAX2=log2(MAX); int d[MAX],h[MAX],P[MAX][MAX2],n; vector<vii> graph(MAX); void dfs(int u,int p){ P[u][0]=p; h[u]=h[p]+1; for(auto k:graph[u]){ if(k.F==p)d[u]=d[p]+k.S; else dfs(k.F,u); } } void init(){ for(int i=0;i<n;++i){ for(int j=0;(1<<j)<n;++j)P[i][j]=-1; } d[0]=0; h[0]=-1; dfs(0,0); for(int j=1;(1<<j)<n;++j){ for(int i=0;i<n;++i){ if(P[i][j-1]!=-1)P[i][j]=P[P[i][j-1]][j-1]; } } } int lca(int u,int v){ if(h[u]>h[v])swap(u,v); int l=log2(h[v]); for(int i=l;i>=0;--i){ if(h[v]-(1<<i)>=h[u]&&P[v][i]!=-1)v=P[v][i]; } //u and v at same level if(u==v)return u; for(int i=l;i>=0;--i){ if(P[u][i]!=P[v][i]&&P[u][i]!=-1){ u=P[u][i]; v=P[v][i]; } } return P[u][0]; } int query(int u,int v){ int lc = lca(u,v); return d[u]+d[v]-2*d[lc]; } int main(){ int u,v,w,q; si(n); loop(i,1,n){ si(u);si(v);si(w); graph[u].PB(MP(v,w)); graph[v].PB(MP(u,w)); } init(); si(q); while(q--){ si(u);si(v); printf("%d\n",query(u,v)); } return 0; } Edited by author 17.01.2016 01:13 wa#4 for countless times, seek for kind help! thanks var a,b,c,i,k:real; begin read(a,b,c); while a>b do begin a:=a-(a*c/100); I:=i+1; end; write(i); end. variable i should be integer ! |
|