Show all threads Hide all threads Show all messages Hide all messages | accepted | Mikhail | 1821. Biathlon | 22 Jun 2018 17:20 | 1 | //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; vector< tuple <int, int, string> > v; vs ans; int calc() { string ans; cin >> ans; re (ans[0] - '0') * 6000 + (ans[1] - '0') * 600 + (ans[3] - '0') * 100 + (ans[4] - '0') * 10 + (ans[6] - '0'); } int main() { int best = (int) 1e9, n, cur; cin >> n; string str; fo(i, n) { cin >> str; cur = calc(); v.pb(make_tuple(cur + i * 300, cur, str)); } sort(all(v)); int finish, res; fo(i, v.size()) { tie(finish, res, str) = v[i]; if (res < best) { best = res; ans.pb(str); } } sort(all(ans)); cout << ans.size() << endl; for (auto &j : ans) cout << j << '\n'; re 0; } Edited by author 22.06.2018 17:22 | What is test #4? | panLevan | 1821. Biathlon | 9 Feb 2017 17:46 | 3 | Can somebody give me test #4? I'm getting WA 3 q 3:3.3 w 4:4:4 e 1:1.1 answer e It should be like 03:03.3 etc | WA 8? | Denis Astanin (KPI) | 1821. Biathlon | 3 Nov 2014 17:13 | 4 | WA 8? Denis Astanin (KPI) 19 Mar 2011 16:52 I also have problem with test #8. Please post a test case. EDIT: nevermind, I have found a super-stupid mistake, fixed it, and got AC. Hint: if you are having WA 8, then look at your time-parsing code! Edited by author 04.10.2011 11:58 The name of a biathlete is a nonempty string consisting of English letters of length at most 20. | Why WA 2 ? | Milovanov Maxim | 1821. Biathlon | 18 Jun 2014 18:52 | 13 | 3 Masha 91:0.0 Sasha 90:0.0 Vasya 3:0.0 ans: 1 Vasya Edited by author 20.03.2011 12:37 Edited by author 22.03.2011 02:51 Bot not only Vasya? My AC program says 1 Vasya == BTW check test 5 E 1:20.0 D 1:10.0 C 0:30.0 B 0:20.0 A 0.10.0 Ans should be 4 A B C E My solution also says 1 Vasia and for the BTW check test the same answer. but i have wa 4. please give me some other examples. thanks. I'm sorry, of course the answer will be 1 Vasya To daftcoder [Yaroslavl SU]: Your test has a mistake in the last line. It should be like this: 5 E 1:20.0 D 1:10.0 C 0:30.0 B 0:20.0 A 0:10.0 Edited by author 27.07.2011 20:48 3 Masha 91:0.0 Sasha 90:0.0 Vasya 3:0.0 ans: 1 Vasya Edited by author 20.03.2011 12:37 It is not TRUE!!!!!!!!!!!!!!!!!! Edited by author 20.11.2012 12:16 3 Masha 91:0.0 Sasha 90:0.0 Vasya 3:0.0 But in the statement it says it's in MM:SS.D format, so shouldn't it be 91:00.0, 03:00.0, etc.? | HelpPlease (Java) | Testme | 1821. Biathlon | 18 Mar 2014 00:37 | 1 | What is wrong with mycode? it is working in mycomputer but failing in test2 import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; /** * Created by sherxon on 3/17/14. */ public class Biathlon { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=Integer.parseInt(in.nextLine()); String s, name, time; Double min, sec; int j=0; List<String> a= new ArrayList(); ArrayList<Double> b= new ArrayList(); int thirty=0; for (int i = 0; i <n ; i++) { s = in.nextLine(); name=s.split(" ")[0]; sec=Double.parseDouble(s.split(" ")[1].split(":")[1])+60*(Double.parseDouble(s.split(" ")[1].split(":")[0])); sec+=thirty; //System.out.println(sec); double eachsec=0.0; double eachsecs=0.0; boolean bl=true; for (int k = 0; k<a.size() ; k++) { // System.out.println(sec-thirty + " " + (b.get(k)-eachsec) + " " +(sec) + " " + b.get(k)); if(sec-thirty<b.get(k)-eachsec&&sec<b.get(k)){ b.remove(k); a.remove(k); k--; } eachsec+=30; } for (int k = 0; k <a.size() ; k++) { if(sec-thirty>b.get(k)-eachsecs){ bl=false; } eachsecs+=30; } if(bl){ a.add(name); b.add(sec); } thirty+=30; } Collections.sort(a); System.out.println(a.size()); for (int i = 0; i <a.size() ; i++) { System.out.println(a.get(i)); } } } | WHAT IS TEST #17 | Лерник Казарян | 1821. Biathlon | 26 Dec 2013 19:20 | 1 | | 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 | Решение | Bpgdan Spilniy | 1821. Biathlon | 1 Dec 2012 22:42 | 5 | Решение Bpgdan Spilniy 19 Mar 2011 21:12 Прошу выложить работающее решение на Паскале. Все еще не могу найти у себя ошибку. Спасибо Выложи прогу на паскале, мы попробуем найти ошибку. program Biatlon; {$APPTYPE CONSOLE} uses SysUtils; var n,i,j,t,x,z,q1,q2,q3,a,g1,g2,g3,o: integer; x1,x2: string; s: array[1..100] of string; r: array[1..100] of string; viv: array[1..100] of string; procedure swap(var x8,y: string); var t4: string; begin t4 := x8; x8 := y; y := t4; end; begin g1:=32000; g2:=61; g3:=32000; o:=0; readln(n); for i:= 1 to n do readln(s[i]); for i:= 1 to n do begin t:=Pos(' ',s[i]); x:=length(s[i]); r[i]:=Copy(s[i], t+1, 7); delete(s[i],t,8); z:=pos(':',s[i]); x1:=copy(r[i],z+1,2); x2:=copy(r[i],z+4,4); val(x1,q1,j); val(x2,q2,j); q3:=q1*60+q2; if q3<g3 then begin g3:=q3; o:=o+1; viv[o]:=s[i]; end; end; for j:=1 to o-1 do begin for i:=1 to o-j do begin if viv[i] > viv[i+1] then swap(viv[i],viv[i+1]) end; end; writeln(o); for i:=1 to o do if i=o then write(viv[i]) else writeln(viv[i]); readln; end. Вот вам решение. 1-ый тест обязано проходить. Но почему-то не проходит. Edited by author 01.12.2012 22:49 | what WA#22 ? | DENISKA(SSAU) | 1821. Biathlon | 7 Nov 2012 22:18 | 2 | | Help PLEASE, i don't understand | green_smile | 1821. Biathlon | 9 Oct 2012 23:27 | 2 | input 6 Zaitseva 21:38.2 Hauswald 21:21.0 Boulygina 22:04.4 Henkel 22:06.1 Wilhelm 21:11.1 Jonsson 22:05.8 My program: 4 Hauswald Henkel Wilhelm Zaitseva explain me please what's wrong??? why Henkel isn't in Test? it's code program z1821; var n,i,j,m,x,max,ol:integer; s,s1:string; names:array[1..100]of string; times:array[1..100]of integer; reznames:array[1..100] of string; begin readln(n); j:=1; for i:=1 to n do begin readln (s); while s[j]<>' ' do begin inc(j); end; names[i]:=copy(s,1,j); // delete(s1,1,length(s1)); // s1:=copy(s,j+1,2); // val(s1,times[i],ol); // delete(s1,1,2); // s1:=copy(s,j+4,2); // times[i]:=times[i]*600; // val(s1,x,ol); // times[i]:=times[i]+x*10; // delete(s1,1,1); // s1:=copy(s,j+7,1); // val(s1,x,ol); // times[i]:=times[i]+x; // j:=1; //it's input, don't look on it =) end; for i:=2 to n do times[i]:=times[i]-300*(i-1); max:=times[1]+1; m:=0; j:=1; for i:=1 to n do begin if times[i]<max then begin max:=times[i]; reznames[j]:=names[i]; m:=m+1; j:=j+1; end; end; for i := 1 to m-1 do for j := 1 to m-i do if reznames[j] > reznames[j+1] then begin s1 := copy(reznames[j],1,length(reznames[j])); reznames[j] :=copy(reznames[j+1],1,length(reznames[j+1])); reznames[j+1] :=copy(s1,1,length(s1)); end; writeln(m); for i := 1 to m do writeln(reznames[i]); end. Edited by author 09.10.2012 23:47 | help | Dima | 1821. Biathlon | 1 Aug 2012 04:49 | 2 | help Dima 1 Aug 2012 04:48 var n,i,a,j,m:integer;q:string;b:real; s:array[1..1000]of string; begin readln(n); b:=99999999999; m:=0; for i:=1 to n do begin readln(q); for j:=1 to length(q) do if q[j]=' ' then a:=j; if (((ord(q[a+1])-48)*10+(ord(q[a+2])-48))*60+((ord(q[a+4])-48)*10+(ord(q[a+5])-48))+(ord(q[a+7])-48)/10<b) then begin inc(m); s[i]:=copy(q,1,a-1); b:=((ord(q[a+1])-48)*10+(ord(q[a+2])-48))*60+((ord(q[a+4])-48)*10+(ord(q[a+5])-48))+(ord(q[a+7])-48)/10; end; end; for i:=1 to n do for j:=1 to n-1 do if s[j]>s[j+1]then begin q:=s[j];s[j]:=s[j+1];s[j+1]:=q; end; writeln(m); for i:=1 to n do if s[i]<>'' then writeln(s[i]); end. | WA6 | Andrew Sboev | 1821. Biathlon | 23 May 2012 16:15 | 3 | WA6 Andrew Sboev 28 Apr 2012 16:22 Why? I got AC. If you have WA6 or WA8, for example, it means, that you are parsing time by wrong way. Keep in mind that test 3 A 999:99.9 B 1024:00.0 C 100500:00.0 is correct. Edited by author 27.05.2012 19:55 It's true. The problem statements states that time's format is "mm:ss.d" but in fact time can have more than 5 digits. Re: WA6 Andrew Sboev 23 May 2012 16:15 Yeah, now I'm sure in it :) | Why wa1? | Geeks_Club | 1821. Biathlon | 5 May 2012 17:24 | 7 | My answer to the example is as follows: 3 Hauswald Wilhelm Zaitseva Check my solution please ! Maybe you have extra spaces in the end of each line? the same i think my solution is true and no extra spaces why is wa 1? here the code of the my solution pleas chek: uses SysUtils,math; Type m = record name:string[21]; min:integer; seconds:real; pos:integer; end; Var n,i,c:integer; tmp:string; mas:array[1..101]of m; tmpG1:m; j,Size,k:integer; TopName:array[1..101] of m; t:m; function CompareStr1(const S1, S2: string): Integer; assembler; asm PUSH ESI PUSH EDI MOV ESI,EAX MOV EDI,EDX OR EAX,EAX JE @@1 MOV EAX,[EAX-4] @@1: OR EDX,EDX JE @@2 MOV EDX,[EDX-4] @@2: MOV ECX,EAX CMP ECX,EDX JBE @@3 MOV ECX,EDX @@3: CMP ECX,ECX REPE CMPSB JE @@4 MOVZX EAX,BYTE PTR [ESI-1] MOVZX EDX,BYTE PTR [EDI-1] @@4: SUB EAX,EDX POP EDI POP ESI end; function timeCompare(m1:integer;S1:real;d1:integer; m2:integer; s2:real; d2:integer):boolean; Var ch:boolean; begin if (m1+(floor(d1+s1) div 60))>(m2+(floor(d2+s1) div 60)) then begin ch:=true; end else if(m1+(floor(d1+s1) div 60))=(m2+(floor(d2+s1) div 60)) then begin if (s1+d1-(floor(s1+d1) div 60)*60)>(s2+d2-(floor(s2+d2) div 60)*60) then ch:=true else ch:=false; end else ch:=false; result:=ch; end; begin readln(n); for i:=1 to n do begin readln(tmp); mas[i].name:=Copy(tmp,1,pos(' ',tmp)-1); Delete(tmp,1,pos(' ',tmp)); Val(copy(tmp,1,pos(':',tmp)),mas[i].min,c); Delete(tmp,1,pos(':',tmp)); Val(tmp,mas[i].seconds,c); mas[i].pos:=i-1; end; tmpG1:=mas[1]; TopName[1]:=Mas[1]; j:=1; for i:=2 to n do if timeCompare(TmpG1.min,TmpG1.seconds,TmpG1.pos*30, Mas[i].min,Mas[i].seconds,Mas[i].pos*30){Min>mas[i]} then begin for k:=j downto 1 do if timeCompare(TopName[k].min,TopName[k].seconds,TopName[k].pos*30,Mas[i].min,Mas[i].seconds,Mas[i].pos*30) then dec(j); inc(j); TopName[j]:=Mas[i]; end else if timeCompare(TmpG1.min,TmpG1.seconds,0,Mas[i].min,Mas[i].seconds,0) then begin inc(j); TopName[j]:=Mas[i]; tmpG1:=mas[i]; end; Size:=j; for i:=1 to Size do for j:=1 to Size do begin if CompareStr1(TopName[i].name,TopName[j].name)<0 then begin t:=TopName[i]; TopName[i]:=TopName[j]; TopName[j]:=t; end; end; writeln(size); for i:=1 to size do writeln(Topname[i].name); end. Don't you think that your code is too long and it is difficult to understand? For sure u guys r not the only ones with that problem >.< After i sent my solution i took WA at #1, then i posted : #include <iostream> using namespace std; int main() { cout << "3\nHauswald\nWilhelm\nZaitseva" ; return 0; } and i took WA at #2; Compiled both sources on my machine and the console output was exactly one and the same Q.Q Give us a clue please! Regards, B.P. ! I don't understand well why it works, but when i've changed variable type for sportsmens counting from unsigned char to unsigned short, i've passed this test (despite of maximal count is 100, and correct input/output in my program). I think that if u have any troubles with it, u should try some different variable types and output commands | Help please!!! I'dont understant problem!!! | Enigma [UB of TUIT] | 1821. Biathlon | 18 Apr 2012 19:24 | 5 | Why input 6 Zaitseva 21:38.2 Hauswald 21:21.0 Boulygina 22:04.4 Henkel 22:06.1 Wilhelm 21:11.1 Jonsson 22:05.8 Answer: 3 Hauswald Wilhelm Zaitseva???????/ I found the explanation a bit below: for a contestant to be in the answer, their time must be better than all the previous ones. Complication: more than 1 contestant can be on the track at the same time. I only just realized this. It is very frustrating to not understand the problem requirements, and to code something which turns out to be incorrect. Edited by author 14.12.2011 17:20 Please elaborate more, xerxe. I speak perfect English and yet I don't understand the wording of the problem!! Edited by author 14.12.2011 22:07 The problem states that contestants start each 30 seconds. Let's say that running times are: - Runner1 30:00.0 (starting at 0:00.0, finishing at 30:00.0) - Runner2 29:31.0 (starting at 0:30.0, finishing at 30:01.0) This means that - Runner1 has the best time after 30 minutes from the start of the race - Runner2 has the best time, 1 second after Runner1 So they are both in the top. However, if: - Runner1 30:00.0 (starting at 0:00.0, finishing at 30:00.0) - Runner2 29:29.0 (starting at 0:30.0, finishing at 29:59.0) Then Runner2 finishes BEFORE Runner1, so Runner1 will never have a best time. An explanation for the problem sample is a bit below ( http://acm.timus.ru/forum/thread.aspx?id=26847&upd=634557023855807397). For me, it was easier to explain on this other example. Hope this is clear, good luck! P.S.: I see you already have AC, congratulations! Edited by author 16.12.2011 19:35thank you xerxe for clearly explaination | WA #14 | DarkJedi | 1821. Biathlon | 6 Nov 2011 13:29 | 1 | WA #14 DarkJedi 6 Nov 2011 13:29 Edited by author 06.11.2011 20:58 | Test 3 and 14 | DarkJedi | 1821. Biathlon | 5 Nov 2011 16:47 | 1 | Give test for 3 and 14 please( | How many names should I print every time? | liushujia | 1821. Biathlon | 31 Oct 2011 23:59 | 4 | I don't know why the example output 3 names, why it is three? cause: wheh first contestant finished, he is the best,counter = 1; every next finished (by finish time) compares with the best by running time - if he better, he becomes the best, and we increment counter; finally, we print counter and list of all who became the best in the sample: first finished Zaytseva (at 21:38.2) second finished Hauswald (at 21:21.0 + 30 sec from start = 21:51.0). She becomes the best; next finished Boulygina (at 22:04.4 + 1 min = 23:04.4); next Wilhelm (at 21:11.1 + 2m = 23:11.1). She becomes the best; next Henkel (at 22:06.1 + 1m30s = 23:36.1); last Johnson (at 22:05.8 +2:30 = 24:35.8). Edited by author 08.08.2011 03:05 But why we must calculate finish times if there are given running times. And, Why Hauswald becames the best? Why Wilhelm? Only way to understand this: if Wilhelm comes 1 (21:11.1), then Hauswald 2(21.21.0), and Zaytseva 3 (21.38.2) (by running time). Sorry, if I miss error. Edited by author 01.11.2011 00:00 | WA #2 ? | Uzbek boy | 1821. Biathlon | 26 Oct 2011 01:48 | 2 | WA #2 ? Uzbek boy 11 Oct 2011 03:25 please, give me any test for WA #2 WA#2 Siroj Matchanov [TUIT] 26 Oct 2011 01:48 I'm sick of it. Please explain it to me. I'm getting WA2. What am I doing wrong? This is my code: #include "stdio.h" #include "algorithm" #include "string.h" struct time { double s, os; //os - original time // s - finish time (+id*30) char name[21]; int I; time(const double S = 0, const int id = 0) :s(S), I(id) {} void inc(const int id) { os = s; s += 30*id; } }; int cmp(const void* a, const void* b) { return ( ((time*)a)->s > ((time*)b)->s ); } int cmp2(const void* a, const void* b) { return strcmp(((time*)a)->name, ((time*)b)->name); } int cmp3(const void* a, const void* b) { return ( ((time*)a)->os < ((time*)b)->os ); } int main() { int n; scanf("%d\n", &n); time* ts = new time[n+1]; time* ans = new time[n+1]; int m; float t; for(int i=0; i<n; i++) { scanf("%s %d:%f\n", ts[i].name, &m, &t ); ts[i].s = t + m * 60; ts[i].inc(i); } std::qsort(&ts[1], n-1, sizeof(time), cmp); int j=0; ans[j++] = ts[0]; for(int i=1; i<n; i++) { if( cmp3( &ts[i], &ans[j-1]) ) ans[j++] = ts[i]; } std::qsort(ans,j,sizeof(time),cmp2); printf("%d\n",j); for(int i=0;i<j;i++) printf("%s\n", ans[i].name); delete[] ans; delete[] ts; return 0; } Edited by author 26.10.2011 01:51 | I thought test #4 wass conflicting with the description of the problem - I was wrong | Leonid (SLenik) Andrievskiy | 1821. Biathlon | 7 Jun 2011 22:50 | 1 | Sorry, it was a very stupid bug in my program Edited by author 07.06.2011 22:52 | What test #19?? | Nikita Sivukhin | 1821. Biathlon | 20 Mar 2011 22:44 | 1 | |
|
|