Common Board| Show all threads Hide all threads Show all messages Hide all messages | | If you've got WA #11 | Pavel Khaustov [Tomsk PU] | 1542. Autocompletion | 30 Jun 2018 19:16 | 4 | If you've got WA #11 then your program deals bad with repeatative queries. Try this test: -------------------- 2 acm 10000 acmicpc 10000 2 ac ac --------------------- Correct answer is: --------------------- acm acmicpc acm acmicpc --------------------- this code works fine for above input but still gives wa#11 I believe, this will help you 18 a 10 ba 0 bb 1 bc 1 bd 1 be 1 bf 1 bg 1 bh 1 bi 1 bj 1 bk 1 bl 1 bm 1 bn 1 bo 1 bp 1 bq 1 1 b ba can't be with zero frequency: 1 ≤ n_i ≤ 106 | | question (+) | Vadimov Vasiliy[NNSU] | 1673. Admission to Exam | 29 Jun 2018 19:59 | 3 | Is it true that k=f(n), where f(n) is Euler function? Edited by author 13.02.2009 22:03 Re: question(+) Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 13 Feb 2009 21:56 Yes =) 2 ADMINS: don't delete this hint. Really, it's easy to think it out - harder is to write If anyone got stuck with this. here is the well-known formula for computing phi function: phi(n) = product of [ p^{a - 1} * (p - 1) ], where factorized n = product [ p^a ]. The problem has a pretty fast brute force solution. Once you find a number K such that (K + 1) is prime and K divides phi(n) try to construct n with this prime (multiply by (K + 1) once and continue while phi(n) / (K + 1)^b is a multiple of (K + 1)). | | WA8 | Alloiya | 2056. Scholarship | 28 Jun 2018 20:14 | 1 | WA8 Alloiya 28 Jun 2018 20:14 | | HINT! | Egor Suvorov | 1036. Lucky Tickets | 26 Jun 2018 11:29 | 13 | HINT! Egor Suvorov 20 May 2007 15:45 Answers for big tests is very big. For example, for test "50 500" answer is "854559745684320697549060368131279814466643179689928095831053239604130293492672614469791533133321". Don't use long long or int64! Use long numbers (long arithmetic)! (Длинная арифметика) I dont have idea. Who can explain to me, how to solve this problem? thx a lot. Thank you for your hint,though I know to use long arithmetic(my arithmetic is wrong). I think the answer for the test"50 500" is "2691417369747203226859471552248904568444092968464995017156586373422740263569136967872156335261820969253753890314496",does anybody get the same answer as me? WAITING FOR HELP. I think the answer for the test"50 500" is "2691417369747203226859471552248904568444092968464995017156586373422740263569136967872156335261820969253753890314496",does anybody get the same answer as me? WAITING FOR HELP. The "HINT!" from Yegor Suvorov is correst, so yours is not. Re: HINT! Oleg Strekalovsky [Retired] 8 Feb 2010 01:16 Thanks!!!:) Edited by author 19.11.2010 11:14 Edited by author 28.10.2015 19:11 Yes, I think so! I think the answer for the test"50 500" is "2691417369747203226859471552248904568444092968464995017156586373422740263569136967872156335261820969253753890314496",does anybody get the same answer as me? WAITING FOR HELP. no! the answer is "854559745684320697549060368131279814466643179689928095831053239604130293492672614469791533133321" Edited by author 03.01.2017 23:05 hints :- 50 500 854559745684320697549060368131279814466643179689928095831053239604130293492672614469791533133321 ( this ans is correct ) make sure value of each digit must not exceed 9 | | Some hint. | MrBones | 1943. Space Rummy | 26 Jun 2018 00:15 | 2 | It's really very easy problem! Just shuffle! Indeed, I solved this problem by repeatedly testing random shuffles and printing NO if none of them was winning. | | Wrong Answer on Test Case 2, Help me out | ismail5g | 1086. Cryptography | 25 Jun 2018 19:11 | 1 | #include<bits/stdc++.h> using namespace std; int arr[15000],newarr[15000]; void sieve() { arr[0]=1; arr[1]=1; newarr[1]=2; for(int i=4; i<15000; i+=2) arr[i]=1; for(int i=3; i<15000; i+=2){ if(arr[i]!=1){ for(int j=i*2; j<15000; j+=i){ arr[j]=1; } } } } int main() { int n, t, k=1; sieve(); //cin>>n; for(int i=1; i<15000; i++){ if(arr[i]!=1){ newarr[k]=i; k++; } } cin>>t; while(t--){ cin>>n; cout<<newarr[n]<<endl; } return 0; } | | Hint | KALO | 1246. Tethered Dog | 25 Jun 2018 12:52 | 2 | Hint KALO 21 Nov 2010 18:23 Calculate the signed area of the polygon... Re: Hint Gilles Deleuze 25 Jun 2018 12:52 Firstly, find any point with largest X (or Y) coordinate and then compute the cross product of two vectors formed by two adjacent points and this point. You need to find a point with largest X (or Y) coordinate as the polygon is not convex. | | 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 | | Very funny problem | [MSU Detritus] freopen | 1761. Binary Palindrome | 21 Jun 2018 19:31 | 2 | I wrote suffix automaton, and with it's help i found solution in 5 lines. Hello!How are you?You are very clever!Help me,please))My problem is "Runtime error" | | OMG, this problem is too easy!!!! | bsu.mmf.team | 1761. Binary Palindrome | 21 Jun 2018 19:28 | 4 | It's unbelieveable, how couldn't I solve it during the contest. Just brute-force for finding answers for smalls n... Hmm no, not so easy, if you do it with pen and paper, it's too easy to overlook the palindromes. You need the results for N<40 before the generic solution becomes obvious. Hello!How are you?You are very clever!Help me,please)I'm confused.My problem is "Runtime error" Hello!How are you?You are very clever!Help me,please)I'm confused.My problem is "Runtime error" | | O(n^3) got 0.826s AC! | paulzrm | 1280. Topological Sorting | 21 Jun 2018 17:34 | 1 | I can't belive it! for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if(can[i][j]) for(k=1;k<=n;k++) if(can[j][k]) can[i][k]=1; } } | | segment tree AC 0.015 | _Otabek | 1028. Stars | 21 Jun 2018 03:04 | 1 | | | accepted | Mikhail | 1423. String Tale | 20 Jun 2018 20:48 | 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; void Z_function (string &str, vi &z) { int n = str.size(); z.resize(n, 0); for (int i = 1, l = 0, r = 0; i < n; ++i) { if (i <= r) { z[i] = min(r - i + 1, z[i - l]); } while (i + z[i] < n && str[z[i]] == str[i + z[i]]) ++z[i]; if (i + z[i] - 1 > r) l = i, r = z[i] + i - 1; } } string str, s; vi z; int main() { int n; cin >> n >> str >> s; str += '$'; str += s; str += s; Z_function(str, z); fo(i, (int)z.size()) { if (z[i] == n) { cout << i - n - 1 << endl; re 0; } } cout << -1 << endl; re 0; } | | Теряюсь в догадках, Что не так? | VladGrin | 1585. Penguins | 20 Jun 2018 16:05 | 2 | #include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> int main() { int N; int i; int emp = 0, mac = 0, lit = 0; scanf("%i",&N); char **str = (char**)malloc(N * sizeof(char)); for(i = 0; i < N; i++) str[i] = (char*)malloc(20); fflush(stdin); for(i = 0; i < N; i++) gets(str[i]); for(i = 0; i < N; i++) { if(strcmp(str[i], "Emperor Penguin") == 0) emp++; if(strcmp(str[i], "Macaroni Penguin") == 0) mac++; if(strcmp(str[i], "Little Penguin") == 0) lit++; } if(emp > mac && emp > lit) printf("%s\n", "Emperor Penguin"); if(mac > emp && mac > lit) printf("%s\n", "Macaroni Penguin"); if(lit > mac && lit > emp) printf("%s\n", "Little Penguin"); for(i = 0; i < N; i++) free(str[i]); free (str); return 0; } | | Visual C++ Accepted | mNT | 1068. Sum | 20 Jun 2018 16:00 | 3 | #include <iostream> using namespace std; int main() { int n; int c = 0; cin >> n; if (n>0) { for (int i = 1; i <= n; i++) c += i; cout << c; } else if (n <= 0) { for (int i = n; i <= 1; i++) c += i; cout << c; } return 0; } Mmm... What?) Edited by author 20.06.2018 16:02 | | 1068 | ANTAR NANDI | 1068. Sum | 19 Jun 2018 15:47 | 2 | 1068 ANTAR NANDI 14 May 2018 14:59 | | Why wrong answer? | Hasin Jannat | 1068. Sum | 19 Jun 2018 13:52 | 1 | #include<stdio.h> #include<math.h> int main() { int N,i,sum; scanf("%d",&N); if(abs(N)<= 10000){ if(N > 0){ sum = (N * (N + 1))/2; } else if(N < 0) { sum = ((abs(N)+2) * (N + 1))/2; } printf("%d",sum); } return 0; } Edited by author 19.06.2018 15:45 Edited by author 19.06.2018 15:45 | | Вопрос по правилам игры | Artem Vetik | 1334. Checkers | 18 Jun 2018 23:31 | 1 | 1)Если игрок1 сделал ход b2,а игрок2 сделал ход a1, то в таком случае игрок2 не должен проиграть? 2) При ходах: b2 a1 h8 ... правильный ответ должен быть 3? Так как после хода h8 пешка на a1 может перепрыгнуть пешку на b2. Не могу найти ошибочный тест (На 2 тесте неверный ответ) | | WA #1 | Gleb Ovchinnikov | 1910. Titan Ruins: Hidden Entrance | 18 Jun 2018 19:41 | 1 | WA #1 Gleb Ovchinnikov 18 Jun 2018 19:41 | | WA #8? Your solution is seriously wrong | Vedernikoff 'Goryinyich' Sergey (HSE: АОП) | 2049. Chemistry | 16 Jun 2018 22:42 | 3 | Consider the test "8 6" - there is solution, while your current logic likely outputs "-1" My thanks! It's very useful test. )) |
|
|