Show all threads Hide all threads Show all messages Hide all messages |
If you use cin in C++ | John | 1563. Bayan | 12 Jan 2022 22:36 | 1 |
I had a hard time with this, so hopefully I will save your time. Read input like this: int n; cin >> n; string t; getline(cin, t); // Necessary to process end of first line (nothing after n) .... // Now keep getting each line with getline(cin, t) |
WA Test#7 | Vladimir | 1563. Bayan | 27 Oct 2021 17:08 | 1 |
What is in this Test? What is the difference from previous ones? There are no big numbers, no special cases - as far as I get the task... |
В чём ошибка? Помогите знатоки программирования , пожалуйста)) | Nikita | 1563. Bayan | 18 Dec 2019 17:13 | 2 |
Помогите ,пожалуйста , что не так? #include <iostream> #include <string> using namespace std; int main() { int n, s = 0; cin >> n; string a[1000]; for (int i = 0; i < n; i++) { getline(cin, a[0]); for (int j = n + 1; j < n; j++) { if (a[i] == a[j]) { break; s++; } } } cout << s; return 0; } Edited by author 02.12.2019 20:46 у тебя код неверный Edited by author 18.12.2019 17:14 |
No subject | Roman Hrynevych | 1563. Bayan | 14 Nov 2019 22:45 | 1 |
Edited by author 14.11.2019 22:47 |
C# Please, Help! Where is wrong? | Serge | 1563. Bayan | 12 Jan 2018 05:28 | 1 |
The answer is correct, but it returns an error. Why? Maybe I did not understand the condition of the task correctly, or can the data be specified for which this code will produce the wrong solution? using System; namespace ConsoleApp30 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int x = 0; string[] shoplist = new string[n]; for (int i = 0; i <n; i++) { shoplist[i] = Console.ReadLine(); } for (int i = 0; i < shoplist.Length; i++) { for (int j = i + 1; j<shoplist.Length; j++) { if (shoplist[i] == shoplist[j]) { x++; i++; } else { continue; } } } Console.WriteLine(x); //Console.ReadKey(); } } } |
No subject | Hopelessness | 1563. Bayan | 1 Nov 2017 20:44 | 1 |
Edited by author 01.11.2017 20:58 |
WA Test#3 | vndd | 1563. Bayan | 1 Feb 2017 05:33 | 1 |
Edited by author 16.02.2017 22:39 |
Test 1 is wrong. | umid5566 | 1563. Bayan | 27 May 2016 15:11 | 2 |
|
Why access violation(pascal)? | IT | 1563. Bayan | 18 Mar 2016 22:23 | 1 |
Edited by author 22.03.2016 20:56 Edited by author 22.03.2016 20:56 |
help me please! | 〇$十ვ尸 | 1563. Bayan | 27 Jan 2016 18:39 | 3 |
i have WA on test #3 my code here: #include <iostream> using namespace std; int main() { int n, s = 0; cin >> n;
string *arr = new string[n]; string a; getline(cin, a); for(int i = 0; i < n; i++) { getline(cin, a); for(int j = 0; j < i; j++) { if(a == arr[j]) { s++; break; } else arr[i] = a; } }
cout << s << endl;
return 0; } Edited by author 26.01.2016 21:58 Try test: 2 a a - Your answer is 1, expected is 0 Also your solution has O(n*n) complexity. I expect (or at least hope) you will have TLE. Edited by author 27.01.2016 18:07 Can't edit prev message. > Your answer is 1, expected is 0 Should be: Your answer is 0, expected is 1 |
WA 2. = = | Shyu SeiMin | 1563. Bayan | 4 Nov 2015 12:59 | 4 |
My code: var a:array[1..1000]of string; b:array[1..1000]of integer; n,i,j,m,max:integer; s:string; c:boolean; begin readln(n); for i:=1 to n do begin c:=true; readln(s); for j:=1 to m do if s=a[j] then begin inc(b[j]); c:=false; break; end; if c then begin inc(m); a[m]:=s; inc(b[m]); end; end; for i:=1 to n do if max<b[i] then max:=b[i]; writeln(max); end. I know. I understood that the wrong.^^ |
WA#5 | kitxuli | 1563. Bayan | 18 Oct 2015 19:56 | 2 |
WA#5 kitxuli 18 Oct 2015 18:13 can you give me 5th test, please input contains strings which size is 30. |
please help me find the error | prog_islam | 1563. Bayan | 12 Apr 2015 04:52 | 1 |
that is my code #5 test case is the error #include<iostream> #include<cstring> using namespace std; int main() { char nmat[1000][31]; long int no=0; long int n; cin>>n;
cin.ignore(); if(1<=n && n<=1000) { for(int i=0;i<n;i++) cin.getline(nmat[i],30);
for(int i=1;i<n;i++) { for(int j=i-1;j>=0;j--) { if((strcmp(nmat[i],nmat[j]))==0) { no++; break; }
} }
cout<<no; system("pause"); return 0; }
} |
No subject | prog_islam | 1563. Bayan | 10 Apr 2015 15:10 | 1 |
where is non-zero exit code in my code solving Bayan problem please help me #include<iostream> #include<cstring> using namespace std; int main() { char nmat[1000][31]; int no=0; int n; cin>>n; cin.ignore(); if(1<=n&&n<=1000) { for(int i=0;i<n;i++) cin.getline(nmat[i],30); for(int i=1;i<n;i++) { for(int j=i-1;j>=0;j--) { if((strcmp(nmat[i],nmat[j]))==0) { no++; break; } } }
cout<<no; } system("pause"); return 0; } |
crc16 hash table | Иван | 1563. Bayan | 3 Jun 2014 17:52 | 1 |
crc16 hash table is not working on test 7. someone solved using hash tables? |
Accepted in Java 1.7 | Axmadjon | 1563. Bayan | 1 May 2014 12:20 | 1 |
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class AcmTimusRu { public static void main(String[] args) { Scanner s = new Scanner(System.in); String[] strings = new String[1000]; Set<String> set = new HashSet<String>(); int n, i; n = s.nextInt(); n =n +1; for (i = 0; i < n; i++) { set.add(s.nextLine()); } if (n == set.size()) { System.out.println(0); } else { int n1 = set.size(); n1 = n - n1; System.out.println(n1); } } } Edited by author 01.05.2014 12:20 Edited by author 01.05.2014 12:20 |
AC | Kornilenko Leonid (KHAI) | 1563. Bayan | 15 Nov 2013 12:17 | 2 |
AC Kornilenko Leonid (KHAI) 22 Jan 2008 17:13 0.062s and 2125Kb I solve it on C#. With Hashtable it's very easy. p.s. GL & HF Edited by author 22.01.2008 17:18 Re: AC DaniilMcrose 15 Nov 2013 12:17 With Python's dicts it's easier :) |
What is wrong? WA1 | alexstyle | 1563. Bayan | 15 Sep 2013 20:51 | 1 |
#include <conio.h> #include <algorithm> #include <iostream> #include <cstdio> #include <stdio.h> #include <string.h> using namespace std; int povtor (char str[31],char mas2[1001][31],int mas2len) { int i; for (i=0; i<mas2len; i++) { if (strcmp(str,mas2[i])==0) return 0; } return 1; } int main() { int N; char mas[1001][31]; char mas2[1001][31];
int mas2len=0;
cin >> N; for (int i=0; i<N; i++) { cin >> mas[i]; }
for (int i=0; i<N; i++) { if (povtor(mas[i],mas2,mas2len)) strcpy(mas2[mas2len++],mas[i]); }
cout << N-mas2len;
getch(); } |
Empty lines in test | LostInSpace | 1563. Bayan | 17 Jul 2013 18:20 | 3 |
I'm pass test only after add ignoring for empty input lines. why empty lines present in tests? There is no empty lines in tests. But the input is finished by EOLN, as usual on Timus Online Judge. Edited by author 17.07.2013 18:22 |
Why WA#2 what's wrong? | kami_botanik | 1563. Bayan | 27 Mar 2013 02:21 | 1 |
her's my cod! Please help! using System; namespace ConsoleApplication1 { class Program1563 { static void Main() { int n = int.Parse(Console.ReadLine()); string str; string[] strl = new string[n]; int s = -1; for (int i = 0; i < n; i++) { str = Console.ReadLine(); strl[i] = str; Console.WriteLine("i="+i); for (int j = 0; j < i; j++) { if (str == strl[j]) s++; } }
Console.WriteLine(s); Console.ReadLine(); } } }
|