Common BoardShow all threads Hide all threads Show all messages Hide all messages | AC on python | ivan pasechnik`~ | 2033. Devices | 13 Dec 2018 21:18 | 1 | 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))]) | To Admins: Please Add SBCL (Common Lisp) As A Supported Programming Language | spanner | | 13 Dec 2018 16:57 | 1 | 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. | what's wrong with this code.....???? | shailendrasky | 1293. Eniya | 13 Dec 2018 08:23 | 6 | #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 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 | suggestions for wa1 | OIer_cjf | 1102. Strange Dialog | 12 Dec 2018 14:39 | 5 | 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. | Структуры, указатель, динамический массив | Chika | | 11 Dec 2018 22:10 | 1 | 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 | for anyone who has WA#13 | Najmaddin Akhundov | 1402. Cocktails | 11 Dec 2018 11:31 | 3 | 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 ? | WA6 | ura | 1140. Swamp Incident | 10 Dec 2018 20:32 | 1 | WA6 ura 10 Dec 2018 20:32 | задача оч короткая | mathew | 1264. Workdays | 10 Dec 2018 19:57 | 1 | Edited by author 21.01.2019 19:40 | To admins: Input format question: | lenny | 1039. Anniversary Party | 10 Dec 2018 17:42 | 2 | 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 ! | How can I not Memory Limit Exceeded? | tsinZ_915 | 1039. Anniversary Party | 10 Dec 2018 17:39 | 3 | 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 | Smilodon_am [Obninsk INPE] | 2108. Oleg and Little Ponies | 10 Dec 2018 01:38 | 1 | 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 | I think problem is wrong | JamesBond_007 | 1112. Cover | 9 Dec 2018 19:55 | 1 | 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." ??? | XueMao | 1250. Sea Burial | 9 Dec 2018 18:40 | 3 | 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 | tests | 🦄Imosk72🦄∭GTGU∭ | 1947. Meander | 8 Dec 2018 21:47 | 1 | tests 🦄Imosk72🦄∭GTGU∭ 8 Dec 2018 21:47 /\/\/ \/\/\ /\*\/ \/\/\ /\/\/ ans: FAIL \/\/\ \/\/* //\// \\\// \/\\/ ans: U2 /\/// \/\\/ /\\*\ \/\// /\/\\ ans: WIN \\/// //\// *\\\\ \\\/\ //\// ans: U1 \/\// \/\\\ ///// *\\\\ \//\/ ans: WIN | prolem description didn't say one bank can only buy one detor | Shen Yang | 1652. Banking Crisis | 8 Dec 2018 13:45 | 1 | so this is a NP complete problem ,how can it be solved with 1000 range.. I don't know | WA on test 5 | Abhishek | 1471. Distance in the Tree | 8 Dec 2018 12:26 | 2 | 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 | vessel | 1471. Distance in the Tree | 8 Dec 2018 11:57 | 2 | WA#4 vessel 6 Dec 2006 18:05 wa#4 for countless times, seek for kind help! thanks Re: WA#4 MOPDOBOPOT (USU) 8 Dec 2018 11:57 | Что не правильно? паскаль | Lena | 1283. Dwarf | 7 Dec 2018 22:02 | 2 | 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 ! | What's wrong? | Markfryazino | 1283. Dwarf | 7 Dec 2018 21:58 | 2 | Here is the code (python 3.6). Can anyone explain, why it fails on test 9? import math string = input().split() start = int(string[0]) end = int(string[1]) commission = int(string[2]) if start <= end: n = 0 else: q = 1 - commission / 100 n = math.log((end / start), q) n = round(n) print(n) Use float / double instead of int ! | WA47 | German | 2102. Michael and Cryptography | 7 Dec 2018 17:07 | 6 | WA47 German 27 Feb 2017 14:20 1) Find the prime numbers up to 10,000,100 (Sieve of Eratosthenes) 2) if the sum is equal to 19 degrees, then the residue is prime to check What can you advise? 1) Up to 10M? 2M is enough. sqrt( 10^18 / 2^18) ~= 1.5M 2) "Yes" precondition: N > 1 "Yes" condition: sum is 20 and residue is 1 "Yes" condition: sum is 19 and residue>1 and residue is prime Could you show please code? AC Edited by author 09.03.2017 18:16 > if (kol == 20){ It's suspicious a bit. Please try test (2^20)*3, expected answer is No 3145728 No 20^20 * 3^1 sum 21 if I understand condition of the problem: 3^1*5^1*7^2*11^1*17^12*23^3 answer is "Yes" ? Edited by author 01.03.2017 13:26 |
|
|