| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Why compilation error? but My compiler run this | Monir | 1068. Сумма | 30 ноя 2019 13:49 | 2 |
#include<stdio.h> #include<math.h> int main(){ int n; scanf("%d",&n); if(n==0){printf("%d",1);} else if(n>0){printf("%d",(n*(n+1))/2);} else{ n=fabs(n); printf("%d",-1*(((n*(n+1))/2)-1)); } return 0; } Edited by author 30.11.2019 13:52 |
| Who can give me an AC program? | zzq | 1090. Теперь ты в армии | 29 ноя 2019 21:54 | 4 |
Who can give me an AC program? no Edited by author 29.11.2019 21:57 Edited by author 29.11.2019 21:57 |
| My AC on C# | Xeqlol | 1026. Вопросы и ответы | 29 ноя 2019 18:29 | 3 |
maybe it is not the best solution, but using System; using System.Collections.Generic; namespace _1026 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<int> z = new List<int>(); for(int i = 0; i < n; i++) z.Add(int.Parse(Console.ReadLine())); z.Sort(); Console.ReadLine(); int k = int.Parse(Console.ReadLine()); for (int i = 0; i < k; i++) Console.WriteLine(z[int.Parse(Console.ReadLine())-1]); } } } well.... C# helps a lot. but i really think figure out yourself is better. PS: no sort is required actually. If you know the length of array it is better to create array, not to use List<>. Array is faster :) In this case you needn`t a lot of economy of time, but in some cases this can be critical. |
| C++ solution | gleb@il | 2023. Дональд-почтальон | 29 ноя 2019 00:31 | 1 |
#include <iostream> #include <set> using namespace std; int main() { int index = 0, cnt = 0, n; set<string> a, b, c; a.insert("Alice"); a.insert("Ariel"); a.insert("Aurora"); a.insert("Peter"); a.insert("Phil"); a.insert("Olaf"); a.insert("Phoebus"); a.insert("Ralph"); a.insert("Robin"); b.insert("Bambi"); b.insert("Belle"); b.insert("Bolt"); b.insert("Mulan"); b.insert("Mowgli"); b.insert("Mickey"); b.insert("Silver"); b.insert("Simba"); b.insert("Stitch"); c.insert("Dumbo"); c.insert("Genie"); c.insert("Jiminy"); c.insert("Kuzko"); c.insert("Kida"); c.insert("Kenai"); c.insert("Tarzan"); c.insert("Tiana"); c.insert("Winnie"); cin >> n; int a1=0,b1=1,c1=2; for(int i = 0; i < n; i++) { string ask; cin >> ask; if(*a.find(ask) == ask) { cnt += abs(index - a1); index = a1; } if(*b.find(ask) == ask) { cnt += abs(index - b1); index = b1; } if(*c.find(ask) == ask) { cnt += abs(index - c1); index = c1; } } cout << cnt; } |
| if you have WA6 | Viktor Krivoshchekov`~ | 1501. Чувство прекрасного | 28 ноя 2019 17:15 | 1 |
|
| How to get AC with 0.02 s (mine is 0.7 s)??(-) | Miguel Angel | 1152. Кривые зеркала | 28 ноя 2019 15:20 | 7 |
I used bitwise operations (we can represent each subset as number between 1 and 2^n - 1), this AC'ed with 0.031s, may be you can further improve it .. Well, I used DP on subsets, but can't get faster than 0.093. Is there any special trick? I used bitmask... AC on 0.015 probably they just upgraded the machine from 2011, that's why you are faster than others :P I get 0.015 and used queue for each recount |
| C# | Faxfox | 1149. Танцы синуса | 28 ноя 2019 11:48 | 1 |
C# Faxfox 28 ноя 2019 11:48 using System; class Test { public static void Main() { String strB = ""; String strA = ""; int num = Convert.ToInt32(Console.ReadLine()); int b = 1; for (int a = num; a > 0; a--) { strA = StrAMaker(a); strB = ')' + strA + '+' + b + strB; b++; } string s3 = new string('(', --num); strB = s3 + strB.TrimStart(')'); Console.WriteLine(strB); } public static string StrAMaker (int a) { string s1 = new string(')', a); String s2 = ""; for (int i = 1; i <= a; i++) { if (i % 2 == 0) { s2 = s2 + "sin(" + i + "+"; if (i == a) s2 = s2.TrimEnd('+') + s1; } else { s2 = s2 + "sin(" + i + "-"; if (i == a) s2 = s2.TrimEnd('-') + s1; } } return s2; } } |
| Help me, please! What is wrong? c++ | Koloskova Mariia | 1196. Экзамен по истории | 28 ноя 2019 01:42 | 3 |
#include <iostream> using namespace std; int main() { int n,m,teacher[1500],student[100000],same=0; cin>>n; for(int i=0;i<n;i++) cin>>teacher[i]; cin>>m; for(int i=0;i<m;i++) cin>>student[i];
for(int i=0;i<n;i++) for(int j=0;j<m;j++) if(teacher[i]==student[j]) same++;
cout<<same; return 0; }
Each date is a positive integer not exceeding 10^9, long long int teacher[], student[] #include <bits/stdc++.h> using namespace std; #define ll long long int main(){ int n1, n2; cin >> n1; vector <int> m1; vector <int> m2; m1.resize(n1); for (int i = 0; i < m1.size(); i++) cin >> m1[i]; cin >> n2; m2.resize(n2); for (int i = 0; i < m2.size(); i++) cin >> m2[i]; int sum = 0; sort(m1.begin(), m1.end()); for (int i = 0; i < m2.size(); i++){ if (binary_search(m1.begin(), m1.end(), m2[i])) sum ++; } cout << sum; return 0; } |
| test 7 | Maxim | 1106. Две команды | 27 ноя 2019 12:52 | 3 |
test 7 Maxim 10 дек 2015 16:30 Did you find solution for 7th test? Test 7 please. Edited by author 27.11.2019 12:53 |
| WA#6 | Steve | 1551. Турнир по сумо | 26 ноя 2019 23:46 | 2 |
WA#6 Steve 26 ноя 2019 18:33 Can someone send test 6 please? Thanks Yes i can, but you so glup for this |
| вопрос снят | Desserg | 1502. Точки домино | 26 ноя 2019 11:31 | 2 |
Edited by author 26.11.2019 11:33 Как удалить тему? Edited by author 26.11.2019 11:32 Edited by author 26.11.2019 11:32 |
| Sqrt-Decomposition solution | BasselBakr | 1846. НОД 2010 | 26 ноя 2019 09:18 | 2 |
I used sqrt-decomposition and got AC in 358ms My idea was like this: 1. Keep an array of the elements we have so far 2. For each sqrt-size block of the array compute the GCD 3. To insert an element: append it to the array and update its block 4. To remove an element: swap the element to be deleted with last element (I used a set of pairs<value, index> to get them quickly) and update their blocks Insert (sqrt n) Delete (sqrt n) O(q sqrt n) where n is number of elements in the array Do you mean that after every insertion, we have to update the block containing the element as well as the block size? If block size is also updated, then shouldn't we have to update the whole array we've had so far? I used sqrt too but in a slightly different way from yours. I read all the queries and store all the values of query + to an array, decide the block size and compute GCD for each block. Then I loop the array again to answer the queries. If it is query +, I simply increase the counter x and call GCD(a[1..x]) (because I completely computed GCD of all blocks before). If it is query -, I erase x in the present array. Specifically, I recompute the GCD of the block without erased value x. This way caused me TLE on test #17, though :(( |
| WA for test 5 | Md. Mostafizur Rahman | 2002. Тестовое задание | 26 ноя 2019 01:53 | 2 |
please can anyone tell me what is the test of 5. |
| C++ answer | gleb@il | 2100. Свадебный обед | 26 ноя 2019 00:19 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int n,g=2; cin >> n; for(int i = 0; i < n; i++) { string a; cin >> a; if(a.length() > 4 && a.substr(a.length()-4,a.length()-1) == "+one") g+=2; else g++; } if(g == 13) cout << 1400; else cout << g*100; } |
| WA11 | DSharipov | 1441. Из истории банка Гринготтс | 23 ноя 2019 04:32 | 1 |
WA11 DSharipov 23 ноя 2019 04:32 |
| WHY WA ON TEST #4??I am really stuck in this!!!plz help! | michel mizrahi | 1020. Ниточка | 20 ноя 2019 17:27 | 6 |
I can't understand what's wrong with my code is my algorithm wrong? or what? my code: #include <stdio.h> #include <math.h> double x[102],y[102]; double dist(int i, int j){ int d1=abs(x[i]-x[j]),d2=abs(y[i]-y[j]); if(d1==0) return (d2); else if(d2==0) return (d1); else return sqrt(d1*d1 + d2*d2); } int main(){ int i; double n,s=0,r,pi=2*acos(0); scanf("%Lf %Lf",&n,&r); for(i=0;i<n;i++) scanf("%Lf %Lf",&x[i],&y[i]); for(i=1;i<n;i++) s+=dist(i,i-1); s+=dist(0,n-1); s+=2*pi*r; printf("%.2Lf\n",s); return 0; } if someone can help me I would appreciate very much thanks! Your algorithm is right. But it seems to me very strange, that d1 and d2 in your code are integers, while x and y are not. double x[102],y[102]; double dist(int i, int j){ int d1=abs(x[i]-x[j]),d2=abs(y[i]-y[j]); ...} And double n seems strange to me too. Test #4: 3 1.2 12.24 13.34 0.00 24.75 -33.36 70.12 Solution: 153.41 thank you both of you guys :D!!!!!! (and sorry for my bad english :$) I finally got ac, just some stupid and silly mistakes! the answer should be 149.64 isn't it??? where am I wrong? . Edited by author 20.11.2019 17:29 |
| re16 | Moshkov Danil | 2112. Полевые логи | 20 ноя 2019 12:50 | 2 |
re16 Moshkov Danil 17 ноя 2019 10:44 Edited by author 17.11.2019 11:13 8 A B C D E F G H 6 A HIT B IN HEAD A HIT C IN HEAD A REVIVE B B REVIVE C A HIT D IN HEAD C REVIVE D |
| WA 7 | 👨💻Stepavly👨💻 [ITMO] | 2147. Градостроение | 18 ноя 2019 22:59 | 1 |
WA 7 👨💻Stepavly👨💻 [ITMO] 18 ноя 2019 22:59 Can anyone help me? I have no idea about how this test looks like. |
| WA 30 | Disintegrator | 1389. Дорожные работы | 18 ноя 2019 19:14 | 4 |
WA 30 Disintegrator 8 апр 2014 03:36 I have WA 30, what did you do to AC? Ok, I got AC after lots of WA 30 attempts by iterating over the input in the reversed order, which makes no sense to me. My current best guess is that test #30 is broken, so there are at least two correct answers and it accepts only one of them as correct. Of course, my algo can delete edges in different order depending on the order in which it iterates over them, but I'm pretty sure it always removes the maximum number of edges. |
| idk why but my code do not work on TOJ compiler but it works on my pycharm compiler | Oleg Bozhenov | 1542. Автодополнение | 18 ноя 2019 03:36 | 1 |
So, when user starts looking for words, my program immediately writes the answer. Maybe that's why it isn't correct. For example: user -> 2 user -> ab program -> abc user -> xz program -> xzy |