Общий форумReally fast. for (int k = 0; k < n; ++k) { for (int i = graph[k]._Find_first(); i < n; i = graph[k]._Find_next(i)) { graph[k] |= graph[i]; } } I created array p[1..10000000] of boolean; p[i]=true when exist i in input. But i can t prove that if length of input <=100000 then absent numb <=10000000 because if you will write all numbers from 1 to 10000000. string length will be more than 10^5 Edited by author 11.02.2019 20:58 All compilers are succeed with this code. What's wrong? #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { double buffer[128*1024]; unsigned long long number, n=0; while(cin >> number) { buffer[n]=pow(number,1.0/2.0); n++; } for (int i=n-1;i>=0;i--) { cout << fixed << setprecision(4) << buffer[i] << endl; } return 0; } #pragma comment(linker, "/STACK:16777216") #include <stdio.h> #include <string.h> #define size 20010 char str[size]; char arr[size]; int i=0; void recurse(int low,int high){ int mid; if(low>high) return; mid = (low+high)/2; arr[mid] = str[i++]; recurse(low,mid-1); recurse(mid+1,high); } int main(){ scanf(" %[^\n]s",str); recurse(0,strlen(str)-1); printf("%s\n",arr); return 0; } /*I simply used recursion and its working for all the test I know presently.Please tell me what is the problem in the code*/ the same def solve(str): l = len(str) if l<=2: return str mid = (1+l)//2 return solve(str[1:mid]) + str[0] + solve(str[mid:]) print solve(sys.stdin.readline().strip()) it's working for all the test I know, but get WA3 here Xel,отличное решение! Только вместо функции strip() нужна функция strip('\n'), иначе удаляются все концевые пробелы и этим самым нарушаются входные данные. Edited by author 03.02.2019 13:56 So for this test: 0 0 90 5 0 -0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 correct answer is 31.4159, right? Edited by author 01.02.2019 23:40 It's very funny to read how I tried to solve: 1-st time I forgot to multiply answer by 2 :) 2-nd time I retyped code by forgot to set 'Pascal' (and it was compile error) 3-rd time I forgot 'begin' :) 4-th time I typed task correctly and it was accepted !!! So, programmers, DO NOT HURRY if you don't want to repeat my funny story :) Edited by author 10.09.2004 00:28 In Poland there is a proverb - "Pospiech jest zlym doradca" - "Hurry is a bad adviser" ;) In Russia we say: "Pospeshish - ludey nasmeshish" - "Making it harry you make people laugh at you". It happens simetimes with everyone. Specially, when current cotest is quite durty-solvable... Don't WORRY :).We forgot READLN in another problem... Do you have solution to problem#1407 Did you show a results of input? N=5; A=2; B=3; Answer should be 30 nanokg; i have read 60 kg. What is it?
the panels need processing of both sides. In Thailand, we say : "Slower, a better knife" Problem Election, my submission are 3 times because of the same story as you !! [ 1st - I forgot to print '%' after floating point ] [ 2nd - I put '%' but forgot to print '\n' ] [ 3rd - It was ACCEPTED !! ] In Persian we say "Ajale kare sheytoone" it means that "hurrying is the way of devil" Edited by author 31.10.2009 01:26 In bulgarian it is "Бързата работа срам за майстора" wicch means "Тhe fast work is a shame for the Master". In Vietnamese we say "Muốn nhanh thì phải từ từ" (which means "if you want to be fast, you must be slower") In russian we say "тише едешь, дальше будешь" (which means "if you go slower, you'll be further) same here.. Edited by author 11.12.2017 21:05 the difficulty rangering here is absolutely uncorrect and unjust Edited by author 31.01.2019 04:21 I used template programming to write 3D Fenwick tree and I get "Compiler failed" verdict when compiling with G++ (not "Compilation Error", but "Compiler failed"; no error message). The solution works fine and gets Accepted with Visual Studio and Clang. I assume it is because of the recursive template operations, but it works when I compile it locally with G++ (using the flags provided on help.aspx?topic=cpp). It also work on other online judges, such as codeforces, which also use mingw g++. Could I get some insight on this? I'm curious why this happens. #include <iostream> using namespace std; int main() { long x, y, c, a, b, MIN, MAX; cin >> x >> y >> c; if (x + y < c) { cout << "Impossible"; return 0; } if (x >= c) cout << c << " " << 0; else if (y >= c) cout << 0 << " " << c; else{ if (x < y) cout << x << " " << c - x; else cout << c - y << " " << y ; } } Please, do not publish your accepted solution code on forum. You disable other people to put their mind on the task in such a manner. Please respect other possibility to solve a task on their own. I think that if people don't need an answer they will not watch it. But if they need to see it, an answer is very useful to them, they can find their mistakes and to learn one more variant of programming. Also I watched answers of other people but it absolutely doesn't mean I answered the same on that problems and haven't put my own mind on the tasks. Please, do not publish your accepted solution code on forum. You disable other people to put their mind on the task in such a manner. Please respect other possibility to solve a task on their own. Edited by author 30.01.2019 03:06I did Dijkstra algorithm for S to F, but seems to exceeds time on test #3 ? Anyone got a clue? Tnx in advance Well, I do not know what this test is, but the answer for this test is "No solution". I don't know how to solve this problem with Dijkstra algorithm. My approach is another. Perhaps one pair of tests below can help you to understand the problem more clearely: 7 7 1 2 10 2 3 10 3 4 5 1 5 1 5 6 50 6 7 50 7 3 50 1 4 ans: 156 7 7 1 2 10 2 3 10 3 4 5 1 5 50 5 6 50 6 7 50 7 3 50 1 4 ans: 205 What you need to do is to find the path with maximum weights of all edges while Dijkstra tries to find minimum. You're solving the wrong problem. This is my code. #include <iostream> #include <vector> using namespace std; int main() { int n,a,k=0; cin>>n; vector <int> v; vector <int> sum; vector <int> index; for(int i=0; i<n; i++) { cin>>a; v.push_back(a); } for(int i=1; i<n-1; i++) { sum.push_back(v[i-1]+v[i]+v[i+1]); index.push_back(i); } int max=sum[0]; for(int i=1; i<n; i++) { if(sum[i]>max) {max=sum[i]; k=i;} } cout<<max<<" "<<index[k]+1; system("pause"); return 0; } If you look carefully, you don't get n sums and indexes, but actually n-2 sums and indexes. just be patient while making precalculation :) Жеванный крот, одна халтура! Мало того что английский перевод кривой как рог барана, так ещё и проверяющая система хромает! Отправляем на проверку: Var s, s1: ansistring; a, b: byte; Begin readln(s, s1); val(s[length(s)], b); End. Получаем вполне обоснованный WA1. Теперь дополним: Var s, s1: ansistring; a, b: byte; Begin readln(s, s1); val(s[length(s)], b); val(s1[length(s1)], a); End. Всё, вселенная дрогнула: "Access violation"... *facepalm* И всё бы ничего, но подобное происходит уже где-то раз пятый (в разных задачах). И да, прочитать string целиком, а затем разрезать - выдаёт ту же ошибку AV: Var s, s1: ansistring; i, a, b: byte; Begin readln(s); for i:=1 to length(s) do if s[i]:=' ' then begin val(s[i-1], b); val(s[length(s)], a); break; end; End. Сделайте уже нормальный ввод!!!!1 Edited by author 01.02.2020 21:32 I recommend you this resource: https://e-maxx.ru/algo/bfsalso you can make a function instead of the lyambda, but I just like lyambdas more. #include <iostream> #include <vector> #include <queue> using namespace std; int main() { int N; cin >> N; vector <vector <int>> g(N); int h; for (int i = 0; i < N; i++) { for (;;) { cin >> h; if (!h) break; g[i].push_back(h - 1); } } int n = g.size(); queue<int> q; vector<bool> used(n); vector<int> d(n); int s; auto bfs = [&](int start) { s = start; q.push(s); used[s] = true; while (!q.empty()) { int v = q.front(); q.pop(); for (size_t i = 0; i<g[v].size(); ++i) { int to = g[v][i]; if (!used[to]) { used[to] = true; q.push(to); d[to] = d[v] + 1; } } } }; for (int start = 0; start < n; ++start) if (!used[start]) { bfs(start); } vector <int> ans; for (int i = 0; i < n; i++) { if (d[i] % 2 == 0) ans.push_back(i + 1); } int size = ans.size(); cout << size << '\n'; for (int i = 0; i < size; i++) cout << ans[i] << " "; } Edited by author 26.01.2019 22:53 Edited by author 30.01.2019 03:16 Edited by author 01.02.2020 21:31 using System; using System.Linq; namespace Csharp_1567 { class Program { static void Main(string[] args) { string str1 = Console.ReadLine(); uint sum = 0; int lin = (from n in str1 select n).Count(); for (int i =0;i<lin;i++) { if (str1[i] == 'a' || str1[i] == 'd' || str1[i] == 'g' || str1[i] == 'j' || str1[i] == 'm' || str1[i] == 'p' || str1[i] == 's' || str1[i] == 'v' || str1[i] == 'y' || str1[i] == '_' || str1[i] == '.' || str1[i] == ' ') { sum += 1; continue; } else if (str1[i] == 'b' || str1[i] == 'e' || str1[i] == 'h' || str1[i] == 'k' || str1[i] == 'n' || str1[i] == 'q' || str1[i] == 't' || str1[i] == 'w' || str1[i] == 'z' || str1[i] == ',') { sum += 2; continue; } else sum += 3; } Console.WriteLine(sum); } } } |
|