Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Problem 1010. Discrete Function [why i am getting wrong test case passing] | Amish jha | 1010. Дискретная функция | 23 июл 2022 22:08 | 1 |
/* :::: author:@DEANNOS at CODEFORCES 2022 :::: */ #include <bits/stdc++.h> //using policy based stl #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> using namespace std; #define endl "\n" #define mod 1000000007 #define ll long long #define ld long double #define vi vector<int> #define vll vector<ll> #define pll pair<ll, ll> #define pii pair<int, int> #define ld long double #define ff first #define ss second #define vs vector<string> #define vpll vector<pll> #define vb vector<bool> #define pb push_back #define bg begin() #define mp make_pair #define ed end() #define gi greater<int> () #define srt(v) (sort(all()) #define all(c) (c).begin(), (c).end() #define sz(x) (int)(x).size() #define fo(i,n) for(ll i=0;i<n;i++) #define Fo(i,k,n) for(ll i=k;i<n;i++) const int INF = 1000000000; const int MAX_N = 2e5; /* int fastpower(int x, int y, int mod) { int res = 1; x = x % mod; if (x == 0) { return 0; } while (y > 0) { if (y & 1) { res = (res*x) % mod; } y = y>>1; x = (x*x) % mod; } return res; } */ /* int GCD(int a,int b) { while(b!=0) { int rem=a%b; a=b; b=rem; } return a; } */ ll integer(ll a) { return a >= 0 ? a : -a; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; ll ans1 = 1, ans2 = 2, mx = 0; ll a; cin >> a; for (int i = 1; i < n; i++) { ll b; cin >> b; if (integr(a - b) > mx) { mx = integer(a - b); ans1 = i; ans2 = i + 1; } a = b; } cout << ans1 << ans2 << endl; return 0; } |
If you have WA2 | Andrew Sboev | 1010. Дискретная функция | 27 май 2019 21:32 | 7 |
1) Maybe, you are reading long long variable with this command : scanf("%d",&arr[i]); It is not right. You should do, for example, it with next command scanf("%I64d",&arr[i]); 2) Maybe, you were confused by statement. You have to choose such two points so line that passing through this points has maximal absolute value of inclination, not just inclination. 3) Maybe, you are doing something like this : for ( int i = 1 ; i <= n ; ++i ) { long long d = abs2(arr[i+1] - arr[i]); if ( d > x ) { x = d; m1 = i; } } There is a mistake in first line. Right way is for ( int i = 1 ; i < n ; ++i ) { It was my biggest mistake, because the problem itself is so simple. Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thanks a lot! The definition of inclination is ambiguous in the problem statement. Thanks a lot! I have ignored "absolute value" too. Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! |
what wrong with my code...-_- | noname | 1010. Дискретная функция | 5 авг 2017 19:28 | 2 |
[code deleted] Edited by moderator 02.01.2020 18:17 cout<<"enter a number for the lines "<<endl; Surely that is wrong |
long is not enough | AfraidDiablo | 1010. Дискретная функция | 20 ноя 2016 00:09 | 2 |
In C++, you'd better use "long long" instead of "long". |
WA3 | Dusayarov Alisher | 1010. Дискретная функция | 9 окт 2014 16:12 | 1 |
WA3 Dusayarov Alisher 9 окт 2014 16:12 What is test 3??? Help me!!! Please!!! |
'Each value of the function is longint '..en..it's right i think | 100919CN | 1010. Дискретная функция | 27 дек 2012 20:08 | 1 |
if 'a' and 'b' are both longint,abs(a-b) can be __int64. |
. | Evgeniy Yuryev | 1010. Дискретная функция | 21 июл 2012 01:21 | 1 |
. Evgeniy Yuryev 21 июл 2012 01:21 AC) Edited by author 21.07.2012 01:25 |
help ??? WA #4 | lasha peradze Free University | 1010. Дискретная функция | 26 янв 2012 19:57 | 1 |
#include<iostream> #include<cstdlib> #include<cstdio> #include<cmath> long a[100000]; long b[100000]; long c[100000]; int d[100000]; using namespace std; int main(){ int n; int max; cin>>n; int i; for (i=0; i<n; i++){ cin>>a[i]; d[i]=1; } for (i=0; i<n-1; i++){ float r=1+(a[i+1]-a[i])*(a[i+1]-a[i]); c[i]=sqrt(r);
} for (i=0; i<n-2; i++){ if ((a[i]-a[i+1])==(a[i+1]-a[i+2])){ c[i+1]+=c[i]; d[i+1]=d[i]+1; //cout<<d[i]<<" "; } } max=c[0]; int t=0; for (i=0; i<n-1; i++){ if (max<c[i]) { max=c[i]; t=i; } } // cout<<d[0]<<" "<<d[1]<<" "<<d[2]<<" "<<d[3]<<" "; cout<<t+2-d[t]<<" "<<t+2; system("pause"); } |
Why WA2? May be, someone had same problem? | Kit | 1010. Дискретная функция | 27 ноя 2011 21:47 | 8 |
Why WA2? May be, someone had same problem? My program here: [code deleted] Edited by author 28.03.2005 22:30 Edited by moderator 02.01.2020 18:24 Yahooo!!! I have surmised! "inclination" - it is absolute value, without sign! But author should mentioned it in the task, in my opinion. Yes,you're right! Thank you very much.! The author should mentioned.It is a big problem.I think. yeah,I think it is important. |
Any idea where the mistake is? | Pawel Wanat | 1010. Дискретная функция | 26 фев 2011 19:10 | 5 |
This code gets WA on test 2: [code deleted] & this gets AC: [code deleted] :) Edited by moderator 02.01.2020 18:26 Try to use scanf("%I64d", &tab[i]); Oh! It's like in dev :) thx for info. . The operating system may be windows, not linux, but why it return WA instead of CE? Edited by author 27.07.2009 20:46 Cause your solution is wrong. |
long long wa@test2,,,and __int64 got AC,, | acmore | 1010. Дискретная функция | 27 июн 2010 16:25 | 2 |
I also have this weird problem. Long long variables got WA@2, and if changed to long double everything is AC... |
Test 2# | Element | 1010. Дискретная функция | 6 мар 2010 13:35 | 2 |
Just change longint into int64. Oh,my god! Don't the author say all values are longint? |
C compiler does not follow C99 Standard | Tony Beta Lambda | 1010. Дискретная функция | 25 фев 2010 12:24 | 3 |
C99 7.20.6.1: long long int llabs(long long int j); but when I submit my code with use of llabs, I got CE. fmax(double,double) also doesn't work well LLONG_MAX will get CE too. |
Be careful with ABS if you use long long! | Tracy.Ennal.Tasgen | 1010. Дискретная функция | 25 июл 2009 06:14 | 3 |
If you use long long,ABS does not work,as this got WA on #2 [code deleted] But this got AC! [code deleted] Edited by moderator 02.01.2020 18:27 This solution isn't good at all.May be there will be points a[0] and a[n] that maxn=abs2(a[0]-a[n]).Your program don't work this time. |
To those who get WA on testcase2 | lonelycorn | 1010. Дискретная функция | 19 июл 2009 19:23 | 7 |
remeber that "Each value of the function is longint (signed long in C++)",so if value[i]=-maxlongint and value[j]=maxlongint then abs(value[i]-value[j])>maxlongint so DO use long long or int64.(i got WA just because of it for 10 times) so do i i got wa for nearly ten times Edited by author 19.07.2009 19:24 |
who WA 2?? come in!I will help you! | junsuper | 1010. Дискретная функция | 6 мар 2009 10:00 | 4 |
input 5 1 1 1 1 1 correct answer 1 2 This test I'm right 。But I WA 2 again |
"inclination" = abs(inclination) | Jason911 | 1010. Дискретная функция | 30 ноя 2008 03:06 | 2 |
I WAed many times for this........ RPWT..................-_-||| 囧。。。 Thanks a lot, I've sent my solution 8 times before reading this post, and of course they have failed. |
if WA for test 2 | rakeshvarna | 1010. Дискретная функция | 23 ноя 2008 00:50 | 1 |
i used long in java and got AC |
don't use longint | panfei | 1010. Дискретная функция | 1 ноя 2008 18:24 | 1 |
1、The value of the function can be a real. Use extended to solve the problem and you will get AC. 2、The progblem says that the line is above the points between the begining and the end of the line,not 'all of the points'. May the force be with you. |
Does "inclination" mean a or tan(a)? | sweetstrawberry | 1010. Дискретная функция | 15 июн 2008 21:57 | 1 |
|