| Show all threads Hide all threads Show all messages Hide all messages |
| weak tests | falicos | 1592. Chinese Watches | 11 Aug 2017 21:18 | 1 |
my program as many others in net got AC but failed on test 3 1:00:00 12:59:58 12:59:59 Correct answer is 1:00:00 but not 13:00:00. |
| #test 11 | liudy | 1781. Clean Code | 11 Aug 2017 16:43 | 1 |
Can someone give me some hints about what #test 11 is? |
| WA 7, WA 8 | 💻Evgeny Nemtsev [UrFU FT-17] | 1608. Lucky Tickets 2008 | 10 Aug 2017 22:53 | 1 |
WA 7, WA 8 💻Evgeny Nemtsev [UrFU FT-17] 10 Aug 2017 22:53 |
| How to solve this problem without long arithmetic? | __Andrewy__ | 1103. Pencils and Circles | 10 Aug 2017 16:38 | 1 |
If i use double -> big error If i use long long -> overflow now i got Runtime error on java. Where I am wrong? I think my function Less is bad but I can't find mistake. My code: import java.math.*; import java.util.*; public class BigNumbers { final int tmax=100; MathContext mc = new MathContext(tmax);
final int nmax=5005;
static int Pox[], Poy[], id[]; static BigDecimal Px[], Py[]; static int n, left;
public static boolean Less(BigDecimal x1, BigDecimal y1, BigDecimal x2, BigDecimal y2) { return (y1.compareTo(BigDecimal.ZERO)!=-1) && (y2.compareTo(BigDecimal.ZERO)==1) && ((y1.multiply(x2)).compareTo(x1.multiply(y2))==-1) || (y1.compareTo(BigDecimal.ZERO)==-1) && ((y2.compareTo(BigDecimal.ZERO)!=-1)) || ((x1.multiply(y2)).compareTo(x2.multiply(y1))==1); }
public static BigDecimal modul2(BigDecimal x, BigDecimal y) { return (x.multiply(x)).add(y.multiply(y)); }
public static void QSort(int L, int R) { int m=(L+R)/2; int i=L; int j=R;
while(i<=j) { while(Less(Px[i],Py[i],Px[m],Py[m])) i++; while(!Less(Px[j],Py[j],Px[m],Py[m]) && j!=m) j--; if(i<=j) { BigDecimal Y=Px[i]; Px[i]=Px[j]; Px[j]=Y; Y=Py[i]; Py[i]=Py[j]; Py[j]=Y; int y=id[i]; id[i]=id[j]; id[j]=y; i++; j--; } } if(L<j) QSort(L, j); if(i<R) QSort(i, R); }
public static void main(String args[]) { Scanner sc=new Scanner(System.in); n=sc.nextInt();
Pox=new int[n+1]; Poy=new int[n+1]; id=new int[n+1]; Px=new BigDecimal[n+1]; Py=new BigDecimal[n+1];
for(int i=1;i<=n;i++) { int x, y; x=sc.nextInt(); y=sc.nextInt(); Pox[i]=x; Poy[i]=y; }
System.out.println(Pox[1]+" "+Poy[1]);
for(int i=1;i<=n-1;i++) { BigDecimal x=BigDecimal.valueOf(Pox[i+1]-Pox[1]); BigDecimal y=BigDecimal.valueOf(Poy[i+1]-Poy[1]); Px[i]=x.divide(modul2(x,y)); Py[i]=y.divide(modul2(x,y)); id[i]=i+1; }
left=1; for(int i=2;i<=n-1;i++) if(Px[left].compareTo(Px[i])==1 || Px[left].compareTo(Px[i])==0 && Py[left].compareTo(Py[i])==1) left=i;
System.out.println(Pox[id[left]]+" "+Poy[id[left]]);
for(int i=1;i<=n-1;i++) { Px[i]=Px[i].subtract(Px[left]); Py[i]=Py[i].subtract(Py[left]); }
for(int i=left;i<=n-2;i++) { Px[i]=Px[i+1]; Py[i]=Py[i+1]; }
QSort(1,n-2); System.out.print(Pox[id[(n-1)/2]]+" "+Poy[id[(n-1)/2]]); } } |
| Try to consider vertices with the same distance to f from s | Nikita Mogilevets | 2034. Caravans | 10 Aug 2017 10:54 | 1 |
|
| Phobia | retNAN | 1951. Complex Root | 8 Aug 2017 00:35 | 4 |
Phobia retNAN 15 Jun 2013 20:02 Two Complex numbers are equivalent if they have the same moduli and there argument differ by a multiple of 2pi.how best can you solve this without encountering irrational numbers especially when you are dealing with nth root. Edited by author 15.06.2013 20:16 Yes, there's exists solution only in integer numbers for this problem. Edited by author 08.07.2018 15:42 |
| .001 AC solution without memoization . | Rafat Islam | 1044. Lucky Tickets. Easy! | 6 Aug 2017 22:17 | 2 |
#include <bits/stdc++.h> using namespace std ; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define mem(x,val) memset((x),(val),sizeof(x)) #define all(x) x.begin(),x.end() #define pb push_back #define mp make_pair #define PI acos(-1.0) const int INF = 1 << 29 ; typedef long long ll ; int N(int n , int k ) { if(n == 1) return k<10?1:0 ; int sum = 0 ; for(int i = 0 ;i<= 9 && i<=k ; i++){ sum+=N(n-1 , k-i) ; } return sum ; } int main() { int n ,sum = 0 , temp ; scanf("%d" ,&n) ; n/= 2 ;
for(int i = 0 ; i<=n*9 ;i++){ temp = N(n,i) ; sum+=(temp*temp) ; } printf("%d\n" , sum) ; return 0 ; } |
| How to achieve such an incredible speed like MrWindows' 0.4 sec? | Nikita Mogilevets | 2062. Ambitious Experiment | 6 Aug 2017 18:10 | 2 |
I have thought about something like lazy calculations model |
| Newton Raphson instead of sqrt() but getting WA on test case 2 | thanos | 1001. Reverse Root | 6 Aug 2017 10:30 | 3 |
#include<iostream> #include <iomanip> #include<vector> int main(){ long long num; std::vector<double> v; int count=0; while(std::cin>>num){ if(num==0){ v.push_back(num); } else{ int i=0; double n=num/10; while(i<10000){ n=n-(n*n-num)/(2*n); i++; } v.push_back(n); }
} for(int i=v.size()-1;i>=0;i--) std::cout<<std::fixed<<std::setprecision(4)<<v[i]<<std::endl; return 0; } Suppose you have no WA. Then you might have 15000+ square roots by 10000 iterations each (If pay attention there are maximum 256KB of numbers) TLE for sure Yup. I just realized it. But I think it converges to 4 decimal places much, much before 10000 iterations (say, like 300-400). Thanks for the help :) |
| Avoiding TL | vlyubin | 1846. GCD 2010 | 6 Aug 2017 06:31 | 4 |
I was barely able to pass the TL by using the segment tree. That part probably works OK, but what causes troubles is the way I locate the array index by given content value (i.e. we want do delete 8, so I search for 8's index and replace it with 0). For that purpose I was using map from STL and wasn't able to come up with anything better (except some hash-like storage). What did you use for that purpose or could you avoid such situation at all? Thanks. I solved by exactly the same algorithm, but got TLE 16-21. Then I just changed my cin to scanf and got AC for 0.218 Try ios::sync_with_stdio (false) . Report was it success or not. I am interested how useful is ios::sync_with_stdio(false) . Yes it does help. My solution (sqrt) was TLE 17. after this line it is AC 0.421. Just put this into main as the first line. thanks for the suggestion, I was too lazy to use scanf:) dont forget though that if you use this, then you cannot use printf and scanf in the same program with cin |
| Ambiguous problem statement (+) | Alipov Vyacheslav [Tomsk PU] | 1412. Autumn Tide | 5 Aug 2017 22:46 | 2 |
It's a complete disaster! I just don't get it. 1) Quote: "Exactly 1 mm of precipitations fall down on the pitch each minute" Another quote: "You should output the average amount of precipitations (in millimeters) falling on the pitch in a minute." So the reasonable question is: "Why the answer is just the area of the pitch without a small piece??" It shoud be less than one millimeter! Ammount of precipitations is the height of the water column that arises from the surface in a particular period of time. Hence under the umbrellas the ammount equals to zero. And according to the statement the answer is (1 - area_covered_with_umbrellas / area_of_the_pitch). 2) Quote: "All the water that has fallen on an umbrella streams down along the shortest way on the hemisphere." So what? Does it mean that the water from the umbrella falls back on the pitch without changing the answer? Or, may be, it changes somehow the ammount of precipitations in the area near the umbrella... And if the umbrella is on the border of the pitch, than what ammount of water falls outside the pitch - area of spherical sector or area of its projection or area of spherical sector minus area of the layer falling out of the pitch? BTW None of these variants didn't produce the answer given in the sample output. I'd appreciate any information you could give me to remove an ambiguity. 1)HINT: за счёт зонтов осадков может выпасть больше. 2)"Вся вода попавшая на зонт, стекает по радиусам зонта от центра к краям" и затем падает вертикально вниз. |
| attention! you must sort answer! | __Andrewy__ | 1189. Pairs of Integers | 5 Aug 2017 20:58 | 1 |
I got WA4. Then i sorted answer by <length, int, int> and got AC. |
| what wrong with my code...-_- | noname | 1010. Discrete Function | 5 Aug 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 |
| WA20 Resolved. The task is so easy that I have overcomplicated it and failed to solve quick | Nikita Mogilevets | 1796. Amusement Park | 2 Aug 2017 18:26 | 1 |
I was trying to remove from the set first non-zero count money unit that is NOT LESS than ticket But actually the task asks to remove just the FIRST non-zero count money unit If act according to the former strategy you will receive WA20. |
| WA4 | Ctalk3r | 1992. CVS | 2 Aug 2017 00:31 | 2 |
WA4 Ctalk3r 1 Aug 2017 15:23 #include <iostream> #include <vector> using namespace std; string per(int x) { int k(0),b(x); string m; if (x<10) {m+=char(x+'0');return m;} while(x!=0) { x=x/10; k++; } x=b; b=k; string s; while(k>0) { s+=char((x%10)+'0'); x=(x-x%10)/10; k--; } for(int i=0;i<b;i++) m+=s[b-i-1]; return m; } int main() { int n,m,i,j,p,t(1); char s[80]; string Y; vector<int> v; vector<int> w; v.reserve(1); w.reserve(1); scanf("%d",&n); scanf("%d",&m); for(int d=0;d<n;d++) { scanf("%s",s); if(s[0]=='l') { scanf("%d%d",&i,&j); if(j>m) continue; if(t<i) continue; v.push_back(j);w.push_back(i); p=w.size(); for(int x=0;x<p;x++) if(w[x]==i && v[x]<0) {v.erase(v.begin()+x);w.erase(w.begin()+x);} } if(s[0]=='r'&& s[1]=='o') { scanf("%d",&i); p=w.size()-1; while(v[p]<0 || w[p]!=i) p--; v[p]-=1000000;} if(s[0]=='c'&& s[1]=='h') { scanf("%d",&i); if(w.size()>0) { for(int x=w.size()-1;x>=0;x--) if(w[x]==i && v[x]>0) {Y+=per(v[x]);if(d!=n-1)Y+="\n";break;} else if (x==0) {Y+="basic";if(d!=n-1)Y+="\n";} } else {Y+="basic";if(d!=n-1) Y+="\n";} } if(s[0]=='r'&& s[1]=='e') { scanf("%d",&i); p=0; while(v[p]>0 || w[p]!=i) { p++; if(p>w.size()-1) break; } if(p>=0) v[p]+=1000000; } if(s[0]=='c'&& s[1]=='l') { if(t<i) continue; t++; scanf("%d",&i); p=w.size(); for(int x=0;x<p;x++) if(w[x]==i) {v.push_back(v[x]);w.push_back(t);} } } cout<<Y; } I can't make up any new tests. Everything, I tried, works. If you have some ideas, please, help Edited by author 01.08.2017 15:26 Edited by author 01.08.2017 15:28 The problem is connected with recoil |
| WA 8, pls HELP ME! | Bogdanov Klim | 1567. SMS-spam | 2 Aug 2017 00:07 | 2 |
#include <iostream> #include <string> #include <map> #include <vector> #include <cctype> #include <algorithm> #include <math.h> #include <iostream> using namespace std; int main() { int N = 0, k = 0; string s; getline (cin, s); char name; for (auto i = 0; i < (int)s.length(); i++) { name = s[i]; if (name == 'a' || name == 'd' || name == 'g' || name == 'j' || name == 'm' || name == 'p' || name == 's' || name == 'v' || name == 'y' || name == '.' || name == ' ') { k = 1; N += k; } if (name == 'b' || name == 'e' || name == 'h' || name == 'k' || name == 'n' || name == 'k' || name == 't' || name == 'w' || name == 'z' || name == ',') { k = 2; N += k; } if (name == 'c' || name == 'f' || name == 'i' || name == 'l' || name == 'o' || name == 'r' || name == 'u' || name == 'x' || name == '!') { k = 3; N += k; } } cout << N; return 0; } You forgot 'q' in the second if |
| WA test 5. Here is my case | Dang Quang Huy | 1752. Tree 2 | 1 Aug 2017 21:16 | 1 |
2 1 3 1 4 3 5 1 6 4 7 2 8 6 9 8 10 7 ans: 8 or 1 |
| The problem is magic | Nikita Mogilevets | 1602. Elevator | 31 Jul 2017 11:24 | 1 |
The problem is very simple. It is clear from the first glance what is going on. The coding is trivial. The math part is trivial. And... for some reason it is almost impossible to get AC from the first try. |
| Максимальный ответ очень мал | Nikita Mogilevets | 1011. Conductors | 30 Jul 2017 10:23 | 2 |
Можно просто перебирать ответ наименьшего возможного, двойки, пока не найдем нужное значение. Для данного количества жителей можно за log этого количества по времени найти требуемое количество кондукторов. Здесь пишут про int_64, про "не использовать double" и "использовать epsilon=1e-9". В моём варианте такое не нужно Хватило int_32 и double. Никакого epsilon, сравнения непосредственно оператором <=. |
| WA 2, pls help me, what's wrong? | Bogdanov Klim | 1663. The Hobbit or There and Back Again 2 | 29 Jul 2017 23:10 | 2 |
#include <iostream> #include <string> #include <map> #include <vector> #include <cctype> #include <algorithm> #include <math.h> #include <iostream> using namespace std; int main() { int N, ch; int h = 1; int max = 0; int second_max = 0; cin >> N; vector <int> m(N); vector<int> v(N); vector<int> k; for (int i = 0; i < N; i++) { cin >> ch; v[i] = ch; } for(int i = 1; i < N; i++) { if(v[i] > max) { second_max = max; max = v[i]; } else { if (v[i] > second_max) { second_max = v[i]; } } } for (int i = 0; i < N; i++) { if (v[i] != max && v[i] != second_max && v[i] != v[0]) { k.push_back(v[i]); } } sort(begin(k), end(k)); m[0] = v[0]; m[1] = second_max; m[N - 1] = max; for (int i = 2; i < N-1; i++) { m[i] = k[k.size() - h]; h++; } for (auto j = 0; j < N; j++) { for (auto i = 0; i < N; i++) { if(m[j] == v[i]) { cout << i + 1 << " "; i = N; } } } return 0; } Please explain your solution |