Help please! may be swap(2,3),i had wa8 and i swapped(2,3),somewhere //#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; double calc () { int a, b; cin >> a >> b; if (a == 1) re b * 2; if (a == 2) re b; re sqrt(3) * b / 2.0; } int main() { int ans = 0, a, b; double fuck; cin >> a >> b; if (a == 1) fuck = b * 2; if (a == 2) fuck = b * sqrt(2); if (a == 3) fuck = b; int n; cin >> n; fo(i, n) { if (calc() <= fuck) ++ans; } cout << ans << endl; } Help please, what's wrong? Or give some test cases. #include <iostream> using namespace std; struct figure { int type; int size; }; bool (*figureFunction) (int, figure); bool circle (int holeSize, figure inManhole) { if( inManhole.type == 1 ) return holeSize >= inManhole.size; return 2*holeSize >= inManhole.size; } bool triangle (int holeSize, figure inManhole) { if( inManhole.type == 3 ) return holeSize >= inManhole.size ; return holeSize > inManhole.size ; } bool square(int holeSize, figure inManhole) { switch(inManhole.type) { case 1: return sqrt(2)*holeSize >= 2*inManhole.size; case 2: return holeSize >= inManhole.size; case 3: return sqrt(2)*holeSize >= inManhole.size; default: break; } } int testHole( figure hole, figure* manhole, int count) { int willPut = 0; switch( hole.type ){ case 1: figureFunction = &circle; break; case 2: figureFunction = □ break; case 3: figureFunction = ▵ break; default: break; } for( int i = 0; i<count; ++i ) { if(figureFunction( hole.size, manhole[i] )) willPut++; } return willPut; } int main() { figure hole; cin>>hole.type>>hole.size; int count; cin>>count; figure* manhole = new figure[count]; for( int i=0; i<count; ++i ) { cin>>manhole[i].type>>manhole[i].size; } cout<< testHole( hole, manhole, count); delete manhole; return 0; } Edited by author 29.06.2012 18:56 WA#5 2 10 1 3 15 Answer: 1 WA#6 3 10 1 3 11 Answer: 1 circle: maxSize := 2 * a; minSize := 2 * a; square: maxSize := a * sqrt(2); minSize := a; triangle: maxSize := a; minSize := a * sqrt(3) / 2; Thank yo so much ! (i forget about min size triangle :-) ) WA#5 WA5 - Try to put the circle into the square!!! Edited by author 27.07.2013 13:58 Edited by author 27.07.2013 13:58 This is my code. #include<stdio.h> #include<math.h> double min(int t,int s) { switch (t) { case 1: return 2*s; case 2: return (double)s; default: return ((s/2)*sqrt(3.0)); } } double max(int t,int s) { switch (t) { case 1: return 2*s; case 2: return (s*sqrt(2.0)); default: return (double)s; } } void main() { int htype,hsize; int type,size; double max_len,min_len; int n,c=0; int i; scanf("%d %d",&htype,&hsize); max_len=max(htype,hsize); scanf("%d",&n); for (i=0;i<n;i++) { scanf("%d %d",&type,&size); min_len=min(type,size); if (min_len<=max_len) c++; } printf("%d",c); } Please tell me whats wrong.. Perhaps, the error is in the function "min". In case of triangle you return ((s/2)*sqrt(3.0)); But in C++ when "s" is "int" and "2" is "int", you will get not float division but only integer division. So when s==3, for example, ((s/2)*sqrt(3.0))==1*sqrt(3.0) You may write "s/2.0". Thanks..AC now. Such a silly mistake. Why WA on 5 test? the code here: int type = in.nextInt(); int size = in.nextInt(); int n = in.nextInt(); int count = 0; for (int i = 0; i < n; i++) { int curType = in.nextInt(); int curSize = in.nextInt();
if (type == 1) { if (curType == 1 && curSize <= size || curType != 1 && curSize <= 2 * size) { count++; } } if (type == 2) { if (curType == 1 && 2 * curSize <= size* Math.sqrt(2) || curType != 1&&curSize <= size * Math.sqrt(2)) { count++; } } if (type == 3) { if (curType == 1 && 2 * curSize <= size || curType != 1&&curSize <= size) { count++; } } } out.print(count); Почему в тесте 1 ответ 2. Well the answer is obviously 1. Apperently the authors of the problem lack the practical experience of putting things into holes :) But we could gratiously pardon them. After all they provided a clear example that allows us to get some insight of their understanding of the "putting things into holes" business. So we were provided with the opportunity to get this AC :) Probablty because stuff is rotated in SPACE :) Pascal AC Prog:) var a,t,n,i,k:integer; max:real; min:array[1..100] of real; begin readln(t,a); case t of 1: max:=2*a; {circle} 2: max:=a*sqrt(2); {rectangle} 3: max:=a; {triangle} end; readln(n); for i:=1 to n do begin readln(t,a); case t of 1: min[i]:=2*a; 2: min[i]:=a; 3: min[i]:=a*sqrt(3)/2; end; end; for i:=1 to n do if min[i]<=max then inc(k); writeln(k); end. It's very easy question that need's piece of paper and max 30 min. HINT: The sample is true! When we put some shape in another they mustn't be parallel to each other! In other words, we can rotate shape that we are going to put inside another as we want! What to do with triangle? What is the maximum side length that can pass triangle with sides a? I used if (a > size(diameter)) then it can pass. Please give some test with triagles as hole and right answers. By the way, are all sizes given in integes? Edited by author 13.10.2007 19:30 try to rotate triangle and find minimum projection When you bring triangle to other figures you must check triangles height. Max projection is the side: a Min projection: a*root(3)/2 ie tilt the triangle in such a way that one side of it vertical. "a" here is the side length. Inputs are integers. I have one question. (all lengths I express with length squere (kvadrat) 2*radius is long kvadrat How writeln min protection for traingle Well people, I've made corrections to my post. I'd made a silly mistake.Nothing controversial here. The solution: Take the first sample test case: 2 10 3 3 20 1 5 2 11 The max linear size of the hole is 10*root(2). 3 20: Min linear size of the cover is 20*root(3)/2. (doesnt pass through) This is because the triangle can be tilted such that it passes with its projection being 20/root(2)=10*root(2). 1 5: min linear size=10 i.e. the diameter(passes through) 2 11: Min linear size=11 i.e. side of the square.(passes through) Hence the answer is 2. Edited by author 03.12.2007 16:48 for triangle a*sqrt(3)/2 I've made changes to the post. Thanks for the clarification. Help please! Try solve it on Pascal....(My C++ solution has got WA#3, but Pascal has got AC)!!! I also had WA6, now i find mistake. i had mistake in case with two triangle: well is triangle and manhole too. other cases were right |
|