1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | /**************************************** Cat Got Bored *****************************************/ #include <bits/stdc++.h> #define FOR(i, s, e) for(int i=s; i<e; i++) //excluding end point #define loop(i, n) for(int i=0; i<n; i++) //n times #define loop(n) for(int i=0;i<n;i++) // n times #define getint(n) scanf("%d", &n) #define gi(n) scanf("%d",&n) //getint short form #define pb(a) push_back(a) #define sqr(x) (x)*(x) #define CIN ios_base::sync_with_stdio(0); cin.tie(0); #define ll long long int #define ull unsigned long long int #define dd double #define d double #define SZ(a) int(a.size()) #define read() freopen("input.txt", "r", stdin) #define write() freopen("output.txt", "w", stdout) #define mem(a, v) memset(a, v, sizeof(a)) #define ms(a,b) memset(a, b, sizeof(a)) #define all(v) v.begin(), v.end() #define pi acos(-1.0) #define pf printf #define sf scanf #define mp make_pair #define paii pair<int, int> #define padd pair<dd, dd> #define pall pair<ll, ll> #define fr first #define sc second #define getlong(n) scanf("%lld",&n) #define gl(n) scanf("%lld",&n) #define CASE(n) printf("Case %d: ",++n) #define inf 1000000000 //10e9 #define EPS 1e-9 int area(int x1,int y1,int x2,int y2) { return (x2-x1)*(y2-y1); } int main() { int night_no; cin>>night_no; int nt = 0; while(night_no--) { int g1_llx,g1_lly,g1_urx,g1_ury;//ll == lower left // ur = upper right //g1 = guard 1 int g2_llx,g2_lly,g2_urx,g2_ury; cin>>g1_llx>>g1_lly>>g1_urx>>g1_ury; cin>>g2_llx>>g2_lly>>g2_urx>>g2_ury; int ll_x_max = max(g1_llx,g2_llx); int ll_y_max = max(g1_lly,g2_lly); int ur_x_min = min(g1_urx,g2_urx); int ur_y_min = min(g1_ury,g2_ury); int strong_sec_ar =0; if(ur_x_min > ll_x_max) if(ur_y_min > ll_y_max) { strong_sec_ar = (ur_x_min - ll_x_max)*(ur_y_min - ll_y_max); } int weak_sec_ar = area(g1_llx,g1_lly,g1_urx,g1_ury) + area(g2_llx,g2_lly,g2_urx,g2_ury) ; weak_sec_ar -= 2*strong_sec_ar; int not_sec_ar = 100*100; not_sec_ar -= weak_sec_ar + strong_sec_ar ; printf("Night %d: %d %d %d\n",++nt,strong_sec_ar,weak_sec_ar,not_sec_ar); } return 0; } |
মঙ্গলবার, ১০ নভেম্বর, ২০১৫
UVA 11639 Guard The Land
এতে সদস্যতা:
পোস্টগুলি (Atom)