Common Board| Show all threads Hide all threads Show all messages Hide all messages | | C# неправильный ответ | Ivan_Popovich | 1787. Turn for MEGA | 16 Dec 2018 15:45 | 1 | помогите найти ошибку. вроде ответы правильные выдаёт using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp3 { class Program { static void Main(string[] args) { string[] a = Console.ReadLine().Split(); int b = Convert.ToInt32(a[0]); int c = Convert.ToInt32(a[1]); int d = 0; string[] e = Console.ReadLine().Split(); for (int f = 0; f < c; f++ ) { d = d + Convert.ToInt32(e[f]); } int g = d - b * c; if (g < 0) { g = 0; } Console.WriteLine(g); Console.ReadLine(); } } } | | PASCAL WHY WA1?? | phloyd | 1493. One Step from Happiness | 15 Dec 2018 04:31 | 2 | Am I stupid or what? code seems to be working var x,a,b:integer; function sum(x:integer): INTEGER; var s:integer; begin while x>0 do begin s:=s+x mod 10; x:=x div 10; end; sum:=s; end; begin read (x); a:=x div 1000; b:=x mod 1000; if (sum(a)=sum(b+1)) or (sum(a)=sum(b-1)) then writeln ('Yes') else writeln ('No'); end. Pay attention to inc and dec in your code. You should do first x+1 and x-1. I hope you understand me | | WA#18 | Tural Vugar Gulmammadov | 1777. Anindilyakwa | 13 Dec 2018 21:41 | 8 | WA#18 Tural Vugar Gulmammadov 9 Oct 2010 16:21 Can someone give me test #18??? Or give me some tests and answers??? Re: WA#18 Tural Vugar Gulmammadov 9 Oct 2010 17:03 For: 75000000000000000 50000000000000000 25000000000000000 answer is 2 (1 ≤ x1, x2, x3 ≤ 10^18) Try to use int64 Re: WA#18 Tural Vugar Gulmammadov 9 Oct 2010 20:22 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. Re: WA#18 1_\/_@_|-|_ _ |>_/-\_$_E_4_|<_1_|-|_``~ 13 Dec 2018 21:41 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 | | WA #19 | FrostCode | 1777. Anindilyakwa | 13 Dec 2018 21:41 | 2 | WA #19 FrostCode 29 Aug 2013 16:46 I didn't find a mistake in my program. And what is the test #19? I'am confused( Re: WA #19 1_\/_@_|-|_ _ |>_/-\_$_E_4_|<_1_|-|_``~ 13 Dec 2018 21:41 45 1 12 it was helped me. Good luck, bro! | | AC on python | 1_\/_@_|-|_ _ |>_/-\_$_E_4_|<_1_|-|_``~ | 2033. Devices | 13 Dec 2018 21:18 | 1 | AC on python 1_\/_@_|-|_ _ |>_/-\_$_E_4_|<_1_|-|_``~ 13 Dec 2018 21:18 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.....???? | yks | 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 | | задача оч короткая | dasw35 | 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? | clavichord | 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 ? See here (+) Dmitry 'Diman_YES' Kovalioff. Retired 20 Mar 2003 17:35 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 |
|
|