Общий форумMax distance may be equal 5e4 * 1e3 = 5e7. I use INF = 1e6 and spent all day to find this bug. //We need to sort out 3 in the second power of the options for the arrangement of signs #include <iostream> using namespace std; int main() { int a, b, c, min; cin >> a >> b >> c; min = a + b + c; if(a + b - c < min) min = a + b - c; if(a - b + c < min) min = a - b + c; if(a - b - c < min) min = a - b - c; if(a - b + c < min) min = a - b + c; if(a - b * c < min) min = a - b * c; if(a * b * c < min) min = a * b * c; if(a * b + c < min) min = a * b + c; if(a * b - c < min) min = a * b - c; cout << min; return 0; } Is it right that p is divisor of n? If not, Can you write example? for each step d len of period equals to gcd(d, n) Edited by author 14.08.2020 21:59 I think, this should be renamed to "Cipher Message 4" Edited by author 13.08.2020 12:24 Edited by author 13.08.2020 12:24 UPD: i have find mistake Edited by author 13.08.2020 00:16 PLEASE!!!! Maybe it's because of accuracy? (in case you are still alive) was it because of accuracy ? I was using doubles and got WA8 due to precision error, but then I changed all of the doubles to pair<long long, long long> (trying to represent them as rational fractions without any loss of accuracy) and got AC. Edited by author 10.08.2020 14:42 Edited by author 10.08.2020 15:53 Input in the task looks like: 13 14.1 Not like: 13 14.1 So change input in your program to p,q=map(float, input().split()) 0.046 - O(p) solution. 0.468 - O(p^2) solution, please add more tests. UPD: understood, that there is cant be NO SOLUTION. But you can enlarge p. Edited by author 10.08.2020 12:39 this is my code a=int(input()) b = [int(a) for a in input().split()] c=int(input()) d = [int(c) for c in input().split()] e=int(input()) f=[int(e) for e in input().split()] spisok=b+d+f spisok.sort() kolich=0 for i in range(0, len(spisok)-1): if spisok[i-1]==spisok[i] and spisok[i]==spisok[i+1]: kolich+=1 print(kolich) i dont know why but it writes wrong answer on test №37 please could you text me what is on this test #include <bits/stdc++.h> #include<cstdio> #include <queue> #define pb push_back #define mp make_pair //Macro #define eps 1e-9 #define pi acos(-1.0) #define ff first #define ss second #define re return #define QI queue #define SI stack #define SZ(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define sq(a) ((a)*(a)) #define distance(a,b) (sq(a.x-b.x) + sq(a.y-b.y)) #define iseq(a,b) (fabs(a-b)<eps) #define eq(a,b) iseq(a,b) #define ms(a,b) memset((a),(b),sizeof(a)) #define G() getchar() #define MAX3(a,b,c) max(a,max(b,c)) #define II ( { int a ; read(a) ; a; } ) #define LL ( { Long a ; read(a) ; a; } ) #define DD ({double a; scanf("%lf", &a); a;}) double const EPS=3e-8; using namespace std; #define FI freopen ("input_B.txt", "r", stdin) #define FO freopen ("output_B.txt", "w", stdout) typedef long long Long; typedef long long int64; //For loop #define forab(i, a, b) for (__typeof (b) i = (a) ; i <= b ; ++i) #define rep(i, n) forab (i, 0, (n) - 1) #define For(i, n) forab (i, 1, n) #define rofba(i, a, b) for (__typeof (b)i = (b) ; i >= a ; --i) #define per(i, n) rofba (i, 0, (n) - 1) #define rof(i, n) rofba (i, 1, n) #define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i) #define for1(i, a, b) for(int i=a; i<b; i++) template< class T > T gcd(T a, T b) { return (b != 0 ? gcd(b, a%b) : a); } template< class T > T lcm(T a, T b) { return (a / gcd(a, b) * b); } #define __(args...) {dbg,args; cerr<<endl;} #define __1D(a,n) rep(i,n) { if(i) printf(" ") ; cout << a[i] ; } #define __2D(a,r,c,f) forab(i,f,r-!f){forab(j,f,c-!f){if(j!=f)printf(" ");cout<<a[i][j];}cout<<endl;} signed main () { ios_base :: sync_with_stdio(0);cin.tie(0);cin.tie(0); int n; unsigned int a; priority_queue <unsigned int> pq; scanf("%d", &n); bool odd = (n%2==1); for(int i=n/2; i>=0; --i){ scanf("%u", &a); pq.push(a); } n-=n/2+1; for(int i=0; i<n; i++){ scanf("%u", &a); pq.push(a); pq.pop(); } if(odd)printf("%u\n", pq.top()); else{ a=pq.top(); pq.pop(); // cout << fixed << setprecision(1) << (a+pq.top())/2.0 << endl; printf("%.1f\n", (a + pq.top() ) / 2.0); } return 0; } Priority queue uses vector under the hood. How many times vector resized while first for() executed - unknown, what final vector capacity - unknown, was all vector buffers except last freed or they still kept by allocator - unknown. I'd recommend to not use priority queue at all, I'd rather implement custom bike using fixed size buffer and std heap functions There must be no problem with vector - I used it successfully but care about its size in advance (reserve and shrink). Be careful in printing big numbers (float not enough) and in using iterators - this is the problem of memory error could be - you may point to out of vector. Also different compilers use compile program with different size and use different allocators - try to use different compilers. It says, that K is an amount of stones BETWEEN other stones. Why does Test4 answer equal n-1. I suppose it should be n-2, shouldn't it? Edited by author 26.12.2016 16:46 You should read the problem statement more clearly. Since K<N, if the array is sorted then K=N-1. 0) AC solve is DP on tree. 1) In DP inf = 1e9. 2) All test in the forum: 5 5 3 1 1 4 1 10 2 3 20 3 5 20 ans = 21 7 4 1 2 10 1 3 20 2 4 30 2 5 0 3 6 0 3 7 40 ans = 100 4 1 1 2 1 1 3 2 2 4 3 ans = 2 5 1 1 2 1 1 5 0 2 3 0 2 4 0 ans = 1 7 3 1 2 1 1 3 39 2 4 40 2 5 40 3 6 39 3 7 39 ans = 117 5 2 1 3 1 1 4 10 2 3 20 3 5 20 ans = 21 Edited by author 12.05.2008 19:54 thanks a lot for your test cases! Thank you for test data. I suppose there is typo in case #1. Correct answer must be 51. Why in the first example ans=21? I think it must be 51. Why in the first example ans=21? I think it must be 51. First test is incorrect. Q must be <=N-1. I could AC all your tests, but I still got WA. THX My falt was that my inf was too litlle ^^ thx a lot! 吃粪汁啦 第一组和第三组数据吃粪一样的。。。第一组很明显不可能啦 第三组这叫一个苹果“二叉”树 Edited by author 03.12.2011 06:51 Edited by author 03.12.2011 06:51 3-rd test case is incorrect, because "any biparous branch splits up to exactly two new branches" Remember that the tree should always be a tree (you can't split it into several components)... are you sure i think 5 5 mean we must have all vertex ans ans is 51 5 5 3 1 1 4 1 10 2 3 20 3 5 20 ans = 51 no matter who plays first and which sign is between numbers 5 5 4 3 2 1 (2) 1 1 (1) 10 3 3 4 2 5 6 1 9 9 3 (4) wrong answer on 1st test obmanul suka you should output edges in input order a,b = map(int,input().split()) if (a % 2 == 0 and b % 2 != 0): print("yes") else: print("no") because data type should be string, not integer sorry, my bad. data type is correct, but you should input like that: a=int(input()) b=int(input()) Check that you use only shortest routes. I don't have any tests, but when I started checking this, then I got ACC. Таким образом, если для данного перекрёстка нет подразделений СКБ Контур находящихся ближе, чем в 6 кварталах, то мы обозначим его числом 0. Carefully read this part of text. Try n = 100000 and remember that 1e6 * 1e6 > 2e9. |
|