看poj站点上的日期,我应该是在2015年2月就得到Accepted了,运气不错,运行时间排名第2。不过一直没有整理总结思考过程,现在自己机器上的码都找不到了…… 只能从poj上抄下最后一版的代码,之前的思考版本就木了…… 至于下文的总结,基本上是凭回忆了。
Memory: 852K Time: 297MS
Language: C++ Result: Accepted
关于本题,我的思考过程是从简单到复杂,又回到简单,最后又有点复杂。
开了题,扫了一眼,第一反应是这最难不过是中学的几何知识就能搞定的吧,不行就逐格计算,然后累加起来不就是所求面积嘛。于是上手就打算堆代码了,打算边写边想就给它秒了。
写着写着,就发现问题了,总结起来:
瞬间感觉——卡题了。
一边想着,一边在纸上画,感觉有点儿灵感了,就写点儿代码片段验证想法。虽然总体上看只是形成了一些零碎的想法,不成体系,更无法整体解决问题,但是多少也有些收获:
- 总算是基本分析清楚了每个单元格内的计算方法。
- 由于逐个单元计算效率低下;同时精度也低下,很容易超出题目的精度要求,大体上考虑采用先统计计数,再统一计算的办法
有了前边一步的分析,整个解题线条就基本出来了,可以预先计算各种情况下的单元格面积值(经分析,情况并不会太多——7372种(已经忘记怎么算的了……))。然后,对于每组数据:
很快代码堆出来,试跑,立刻发现了问题,小规模测试中,可以看到精度上已经没有问题了。单元格面积值的预算耗时比较久,会TLE(Time Limit Exceeded),怎么搞?
既然在线预先计算比较慢,比较自然的想法是提前线下计算——我也正是这么干的。Duang duang的写预算程序,算出数据表来,新问题又出现了——代码长度超限!(这个错误貌似在问题的Statistics表的表头中都是没有的),怎么搞?
上压缩算法……?!!!LZW?!……
我去,提交个程序还要压缩的……
虽然真是上压缩算法有点儿过分了,但是很快我想到一个替代解决方案,用define实现压缩……
也没有太“使劲儿”,只是将重复的部分进行了替换,看着能提交了就没在“深入研究了”……
Anyway,it works!
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#define Z6 1,11,1
#define Z5 1,57,1
#define Z4 63,4,64
#define Z3 1,300,1
#define Z2 1,47,1
#define Z1 63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,34,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,930,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,34,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,2,63,2,64,930,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,17,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,465,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,17,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,465,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,17,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,465,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,17,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,1,63,1,166,2513,63
using namespace std;
int precalc_zip_size = 5960;
double key_value[] = {1,0.734648,0.735812,0.502416,0.471624,0.270184,0.736972,0.47162,0.504416,0.27102,0.27186,0.07042,0.81936,0.707304,0.610752,0.555172,0.475072,0.346564,0.556332,0.444276,0.379356,0.323776,0.243676,0.1468,0.819984,0.610212,0.708468,0.555796,0.37798,0.44428,0.556956,0.347184,0.477072,0.3244,0.146584,0.244516,0.721568,0.45738,0.45854,0.225984,0.728872,0.67996,0.520264,0.311656,0.465844,0.416932,0.288868,0.111892,0.648624,0.582868,0.537108,0.440016,0.3285,0.385596,0.31984,0.305712,0.20862,0.128736,0.63108,0.422472,0.368052,0.191076,0.010848,0,0.011152,0.821056,0.555704,0.709,0.475604,0.556868,0.323472,0.444812,0.243372,0.612752,0.3474,0.380196,0.649696,0.53764,0.58394,0.385508,0.305408,0.319752,0.441392,0.329336,0.208836,0.730568,0.520796,0.681656,0.46638,0.288564,0.417468,0.522264,0.312492,0.289708,0.632152,0.367964,0.423848,0.191292,0.640416,0.52836,0.44826,0.431808,0.432112,0.320056,0.255136,0.559208,0.510296,0.493452,0.3506,0.284844,0.350904,0.301992,0.173928,0.301688,0.285148,0.541664,0.333056,0.33336,0.156384,0.639968,0.485776,0.528452,0.416936,0.37694,0.222748,0.297056,0.217172,0.550832,0.439316,0.287804,0.20792,0.533288,0.27026,0.64104,0.431268,0.528984,0.351168,0.529524,0.432736,0.222964,0.352852,0.47896,0.413204,0.367444,0.270656,0.2049,0.190772,0.550552,0.39636,0.50164,0.439036,0.390124,0.342248,0.188056,0.262364,0.461416,0.3499,0.253112,0.173228,0.542624,0.430568,0.33432,0.39566,0.412504,0.443872,0.235568,0.01146,0.821676,0.556324,0.612212,0.378816,0.557488,0.324092,0.348024,0.71016,0.444808,0.477604,0.244208,0.641036,0.52898,0.487152,0.376848,0.296748,0.52952,0.417464,0.296964,0.216864,0.650624,0.440852,0.584868,0.386436,0.32068,0.539108,0.306552,0.552208,0.28802,0.440692,0.208136,0.431572,0.351472,0.432428,0.352544,0.550548,0.501636,0.396664,0.34194,0.439032,0.39012,0.262056,0.479264,0.413508,0.367748,0.46172,0.350204,0.723568,0.458216,0.45938,0.440152,0.63308,0.423308,0.368892,0.534664,0.270476,0.542928,0.430872,0.412808,0.395964,0.444176,0.64166,0.431888,0.432196,0.25438,0.530144,0.320372,0.45026,0.4703,0.404544,0.316416,0.358784,0.293028,0.2789,0.470608,0.404852,0.359092,0.293336,0.279208,0.381472,0.269956,0.190072,0.543244,0.33378,0.431728,0.452756,0.298872,0.34124,0.315716,0.363928,0.252412,0.543552,0.432036,0.453064,0.341548,0.445136,0.346384,0.642112,0.37676,0.530056,0.29666,0.418,0.21656,0.488532,0.22318,0.470752,0.358696,0.404996,0.278596,0.29294,0.317172,0.205116,0.551624,0.341852,0.502712,0.439568,0.261752,0.390656,0.398044,0.188272,0.453208,0.341152,0.299628,0.389544,0.340632,0.323788,0.258032,0.235964,0.187052,0.274876,0.170208,0.372,0.306244,0.21842,0.461136,0.306944,0.412224,0.363312,0.307556,0.153364,0.323088,0.354456,0.200876,0.651696,0.386344,0.442232,0.53964,0.330176,0.58594,0.320588,0.471056,0.359,0.4053,0.293244,0.480644,0.270872,0.414888,0.368588,0.302832,0.382228,0.270172,0.316472,0.480336,0.36828,0.41458,0.302524,0.389848,0.340936,0.27518,0.318564,0.252808,0.30102,0.235264,0.553588,0.288236,0.441532,0.4631,0.253328,0.351044,0.364684,0.252628,0.252108,0.283476,0.21772,0.561208,0.351436,0.351744,0.512296,0.495452,0.28568,0.258336,0.390156,0.341244,0.275488,0.462792,0.397036,0.372304,0.306548,0.414188,0.372612,0.3237,0.234564,0.265932,0.73226,0.466908,0.522796,0.2894,0.313332,0.683348,0.417996,0.55162,0.439564,0.397736,0.342156,0.502708,0.390652,0.285988,0.41388,0.461132,0.41222,0.307248,0.363308,0.323392,0.634152,0.3688,0.424688,0.350736,0.543664,0.333892,0.3342,0.445248,0.235784,0.453512,0.341456,0.35476,0.258644,0.397344,0.306856,0.536044,0.270692,0.445556,0.34714,0.355068,0.248388};
double precalc_zip[] = {1,0,1,1,1,2,1,3,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1,9,1,8,1,9,1,10,Z6,12,1,13,1,14,1,3,1,15,1,16,1,17,1,5,1,18,1,19,1,20,1,9,1,21,1,22,1,23,Z6,24,1,25,1,26,1,3,1,27,1,28,1,29,1,5,1,30,1,31,1,32,1,9,1,33,1,34,1,35,Z6,36,1,25,1,14,1,3,1,37,1,28,1,17,1,5,1,38,1,31,1,20,1,9,1,39,1,34,1,23,Z6,12,1,13,1,15,1,16,1,14,1,3,1,17,1,5,1,18,1,19,1,21,1,22,1,20,1,9,1,23,Z6,40,1,41,1,42,1,16,1,42,1,16,1,43,1,5,1,44,1,45,1,46,1,22,1,46,1,22,Z2,11,1,48,1,49,1,50,1,16,1,51,1,28,1,52,1,5,1,53,1,54,1,55,1,22,1,56,1,34,Z5,11,1,58,1,49,1,42,1,16,1,59,1,28,1,43,1,5,1,60,1,54,1,46,1,22,1,61,1,34,Z2,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,65,1,66,1,67,1,68,1,69,1,70,1,71,1,72,1,73,1,74,1,8,1,9,1,75,1,23,1,10,Z6,76,1,77,1,78,1,68,1,79,1,80,1,81,1,72,1,82,1,83,1,20,1,9,1,84,Z5,23,Z6,85,1,86,1,87,1,68,1,88,1,89,1,90,1,72,1,91,1,92,1,32,1,9,1,93,Z2,35,Z6,94,1,86,1,78,1,68,1,95,1,89,1,81,1,72,1,96,1,92,1,20,1,9,1,97,Z2,23,Z6,98,2,99,1,100,1,101,1,70,1,81,1,72,1,102,1,103,1,21,1,22,1,104,2,23,Z6,105,1,106,1,107,1,100,1,108,1,80,1,109,1,72,1,110,1,111,1,46,1,22,1,112,1,57,Z2,11,1,105,1,107,1,106,1,100,1,108,1,89,1,113,1,72,1,110,1,114,1,55,1,22,1,112,Z2,57,Z6,115,2,107,1,100,1,116,1,89,1,109,1,72,1,117,1,114,1,46,1,22,1,118,2,47,1,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,24,1,25,1,27,1,28,1,26,1,3,1,29,1,5,1,30,1,31,1,33,1,34,1,32,1,9,1,35,Z6,48,1,49,1,51,1,28,1,50,1,16,1,52,1,5,1,53,1,54,1,56,1,34,1,55,1,22,Z5,11,1,119,1,120,1,121,1,28,1,121,1,28,1,122,1,5,1,123,1,124,1,125,1,34,1,125,1,34,1,126,Z6,127,1,120,1,51,1,28,1,128,1,28,1,52,1,5,1,129,1,124,1,56,1,34,1,130,1,34,Z5,11,1,36,1,25,1,37,1,28,1,14,1,3,1,17,1,5,1,38,1,31,1,39,1,34,1,20,1,9,1,23,Z6,58,1,49,1,59,1,28,1,42,1,16,1,43,1,5,1,60,1,54,1,61,1,34,1,46,1,22,Z2,11,1,127,1,120,1,128,1,28,1,51,1,28,1,52,1,5,1,129,1,124,1,130,1,34,1,56,1,34,Z5,11,1,131,1,120,1,59,1,28,1,59,1,28,1,43,1,5,1,132,1,124,1,61,1,34,1,61,1,34,Z2,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,264,63,1,133,1,134,1,135,1,136,1,137,1,70,1,90,1,72,1,138,1,139,1,33,1,34,1,140,1,23,1,35,Z6,141,2,142,1,136,1,143,1,80,1,113,1,72,1,144,1,145,1,56,1,34,1,146,2,57,Z6,147,1,148,1,149,1,136,1,150,1,89,1,151,1,72,1,152,1,153,1,125,1,34,1,154,Z2,126,Z6,155,1,148,1,142,1,136,1,156,1,89,1,113,1,72,1,157,1,153,1,56,1,34,1,158,Z2,57,Z6,159,1,134,1,160,1,136,1,101,1,70,1,81,1,72,1,161,1,139,1,39,1,34,1,104,2,23,Z6,155,1,142,1,162,1,136,1,108,1,80,1,109,1,72,1,157,1,145,1,61,1,34,1,112,1,57,Z2,11,1,155,1,148,1,163,1,136,1,108,1,89,1,113,1,72,1,157,1,153,1,130,1,34,1,112,Z2,57,Z6,164,1,148,1,162,1,136,1,116,1,89,1,109,1,72,1,165,1,153,1,61,1,34,1,118,2,47,1,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,264,Z1,1,167,1,168,1,169,1,170,1,171,1,172,1,173,1,34,1,174,1,175,1,8,1,9,1,176,1,177,1,10,Z6,178,1,179,1,180,1,170,1,181,1,182,1,139,1,34,1,183,1,184,1,20,1,9,1,185,1,186,1,23,Z6,187,1,188,1,189,1,170,1,190,1,56,1,191,1,34,1,192,1,83,1,32,1,9,1,193,Z5,35,Z6,194,1,188,1,180,1,170,1,195,1,56,1,139,1,34,1,196,1,83,1,20,1,9,1,197,Z5,23,Z6,178,1,179,1,198,1,199,1,200,1,172,1,139,1,34,1,183,1,184,1,21,1,22,1,201,1,177,1,23,Z6,202,1,203,1,204,1,199,1,205,1,182,1,153,1,34,1,206,1,207,1,46,1,22,1,208,1,186,Z2,11,1,209,2,210,1,199,1,144,1,56,1,145,1,34,1,211,1,111,1,55,1,22,1,146,2,57,Z6,212,1,210,1,204,1,199,1,157,1,56,1,153,1,34,1,213,1,111,1,46,1,22,1,158,1,57,Z2,11,128,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,214,1,215,1,169,1,170,1,216,1,39,1,173,1,34,1,73,1,74,1,8,1,9,1,75,1,23,1,10,Z6,194,1,217,1,180,1,170,1,195,1,130,1,139,1,34,1,82,1,83,1,20,1,9,1,84,Z5,23,Z6,218,1,219,1,189,1,170,1,220,1,61,1,191,1,34,1,91,1,92,1,32,1,9,1,93,Z2,35,Z6,221,1,219,1,180,1,170,1,222,1,61,1,139,1,34,1,96,1,92,1,20,1,9,1,97,Z2,23,Z6,223,1,224,1,198,1,199,1,161,1,39,1,139,1,34,1,102,1,103,1,21,1,22,1,104,2,23,Z6,212,1,225,1,204,1,199,1,157,1,130,1,153,1,34,1,110,1,111,1,46,1,22,1,112,1,57,Z2,11,1,212,1,226,1,210,1,199,1,157,1,61,1,145,1,34,1,110,1,114,1,55,1,22,1,112,Z2,57,Z6,227,1,226,1,204,1,199,1,165,1,61,1,153,1,34,1,117,1,114,1,46,1,22,1,118,2,47,1,11,128,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,228,1,229,1,230,1,231,1,232,1,172,1,191,1,34,1,232,1,233,1,33,1,34,1,234,1,177,1,35,Z6,235,1,236,1,237,1,231,1,238,1,182,1,145,1,34,1,238,1,239,1,56,1,34,1,240,1,186,Z5,11,1,241,1,237,1,242,1,231,1,243,1,56,1,244,1,34,1,243,1,145,1,125,1,34,1,245,Z5,126,Z6,246,2,237,1,231,1,247,1,56,1,145,1,34,1,247,1,145,1,56,1,34,1,248,2,57,Z6,249,1,229,1,250,1,231,1,200,1,172,1,139,1,34,1,251,1,233,1,39,1,34,1,201,1,177,1,23,Z6,252,1,236,1,253,1,231,1,205,1,182,1,153,1,34,1,254,1,239,1,61,1,34,1,208,1,186,Z2,11,1,246,1,237,1,255,1,231,1,144,1,56,1,145,1,34,1,247,1,145,1,130,1,34,1,146,2,57,Z6,256,1,237,1,253,1,231,1,157,1,56,1,153,1,34,1,257,1,145,1,61,1,34,1,158,1,57,Z2,11,384,63,1,258,1,250,1,230,1,231,1,259,1,39,1,191,1,34,1,138,1,139,1,33,1,34,1,140,1,23,1,35,Z6,246,1,255,1,237,1,231,1,247,1,130,1,145,1,34,1,144,1,145,1,56,1,34,1,146,2,57,Z6,260,1,253,1,242,1,231,1,261,1,61,1,244,1,34,1,152,1,153,1,125,1,34,1,154,Z2,126,Z6,256,1,253,1,237,1,231,1,257,1,61,1,145,1,34,1,157,1,153,1,56,1,34,1,158,Z2,57,Z6,262,2,250,1,231,1,161,1,39,1,139,1,34,1,161,1,139,1,39,1,34,1,104,2,23,Z6,256,1,255,1,253,1,231,1,157,1,130,1,153,1,34,1,157,1,145,1,61,1,34,1,112,1,57,Z2,11,1,256,1,253,1,255,1,231,1,157,1,61,1,145,1,34,1,157,1,153,1,130,1,34,1,112,Z2,57,Z6,263,2,253,1,231,1,165,1,61,1,153,1,34,1,165,1,153,1,61,1,34,1,118,2,47,1,11,384,Z1,1,65,1,66,1,69,1,70,1,67,1,68,1,71,1,72,1,73,1,74,1,75,1,23,1,8,1,9,1,10,Z6,98,1,99,1,101,1,70,1,99,1,100,1,81,1,72,1,102,1,103,1,104,1,23,1,21,1,22,1,23,Z6,133,1,134,1,137,1,70,1,135,1,136,1,90,1,72,1,138,1,139,1,140,1,23,1,33,1,34,1,35,Z6,159,1,134,1,101,1,70,1,160,1,136,1,81,1,72,1,161,1,139,1,104,1,23,1,39,1,34,1,23,Z6,76,1,77,1,79,1,80,1,78,1,68,1,81,1,72,1,82,1,83,1,84,Z5,20,1,9,1,23,Z6,105,1,106,1,108,1,80,1,107,1,100,1,109,1,72,1,110,1,111,1,112,Z5,46,1,22,Z2,11,1,141,1,142,1,143,1,80,1,142,1,136,1,113,1,72,1,144,1,145,1,146,Z5,56,1,34,Z5,11,1,155,1,142,1,108,1,80,1,162,1,136,1,109,1,72,1,157,1,145,1,112,Z5,61,1,34,Z2,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,264,63,1,264,1,265,1,266,1,267,1,266,1,267,1,268,1,269,1,270,1,271,1,75,1,23,1,75,1,23,1,10,Z6,272,1,273,1,274,1,267,1,273,1,275,1,276,1,269,1,277,1,278,1,104,1,23,1,84,Z5,23,Z6,279,1,280,1,281,1,267,1,282,1,283,1,284,1,269,1,285,1,286,1,140,1,23,1,93,Z2,35,Z6,287,1,280,1,274,1,267,1,288,1,283,1,276,1,269,1,289,1,286,1,104,1,23,1,97,Z2,23,Z6,272,2,273,1,275,1,274,1,267,1,276,1,269,1,277,1,278,1,84,Z5,104,2,23,Z6,290,1,291,1,292,1,275,1,292,1,275,1,293,1,269,1,294,1,295,1,112,Z5,112,1,57,Z2,11,1,290,1,292,1,291,1,275,1,292,1,283,1,296,1,269,1,294,1,297,1,146,Z5,112,Z2,57,Z6,298,2,292,1,275,1,299,1,283,1,293,1,269,Z3,297,1,112,Z5,118,2,47,1,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,264,63,1,85,1,86,1,88,1,89,1,87,1,68,1,90,1,72,1,91,1,92,1,93,Z2,32,1,9,1,35,Z6,105,1,107,1,108,1,89,1,106,1,100,1,113,1,72,1,110,1,114,1,112,Z2,55,1,22,Z5,11,1,147,1,148,1,150,1,89,1,149,1,136,1,151,1,72,1,152,1,153,1,154,Z2,125,1,34,1,126,Z6,155,1,148,1,108,1,89,1,163,1,136,1,113,1,72,1,157,1,153,1,112,Z2,130,1,34,Z5,11,1,94,1,86,1,95,1,89,1,78,1,68,1,81,1,72,1,96,1,92,1,97,Z2,20,1,9,1,23,Z6,115,1,107,1,116,1,89,1,107,1,100,1,109,1,72,1,117,1,114,1,118,Z2,46,1,22,Z2,11,1,155,1,148,1,156,1,89,1,142,1,136,1,113,1,72,1,157,1,153,1,158,Z2,56,1,34,Z5,11,1,164,1,148,1,116,1,89,1,162,1,136,1,109,1,72,1,165,1,153,1,118,Z2,61,1,34,Z2,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,264,63,1,279,1,280,1,282,1,283,1,281,1,267,1,284,1,269,1,285,1,286,1,93,Z2,140,1,23,1,35,Z6,290,2,292,1,283,1,291,1,275,1,296,1,269,1,294,1,297,1,112,Z2,146,2,57,Z6,301,1,302,1,303,1,283,1,303,1,283,1,304,1,269,1,305,1,306,1,154,Z2,154,Z2,126,Z6,298,1,302,1,292,1,283,1,307,1,283,1,296,1,269,Z3,306,1,112,Z2,158,Z2,57,Z6,287,1,280,1,288,1,283,1,274,1,267,1,276,1,269,1,289,1,286,1,97,Z2,104,2,23,Z6,298,1,292,1,299,1,283,1,292,1,275,1,293,1,269,Z3,297,1,118,Z2,112,1,57,Z2,11,1,298,1,302,1,307,1,283,1,292,1,283,1,296,1,269,Z3,306,1,158,Z2,112,Z2,57,Z6,308,1,302,1,299,1,283,1,299,1,283,1,293,1,269,1,309,1,306,1,118,Z2,118,2,47,1,11,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,8,63,8,62,264,Z1,1,310,1,311,1,312,1,84,1,313,1,299,1,314,Z5,315,1,316,1,75,1,23,1,176,1,177,1,10,Z6,317,1,318,1,277,1,84,1,318,1,240,1,278,Z5,319,1,320,1,104,1,23,1,185,1,186,1,23,Z6,321,1,322,1,323,1,84,1,324,1,146,1,325,Z5,323,1,278,1,140,1,23,1,193,Z5,35,Z6,326,1,322,1,277,1,84,1,327,1,146,1,278,Z5,328,1,278,1,104,1,23,1,197,Z5,23,Z6,329,1,330,1,322,1,146,1,331,1,299,1,278,Z5,331,1,332,1,84,Z5,201,1,177,1,23,Z6,333,1,334,1,294,1,146,1,172,1,240,1,297,Z5,172,1,335,1,112,Z5,208,1,186,Z2,11,1,336,2,337,1,146,1,337,1,146,1,295,Z5,337,1,295,1,146,Z5,146,2,57,Z6,338,1,337,1,294,1,146,1,339,1,146,1,297,Z5,339,1,295,1,112,Z5,158,1,57,Z2,11,384,63,1,340,1,341,1,312,1,84,1,342,1,197,1,314,Z5,270,1,271,1,75,1,23,1,75,1,23,1,10,Z6,326,1,327,1,277,1,84,1,327,1,248,1,278,Z5,277,1,278,1,104,1,23,1,84,Z5,23,Z6,343,1,344,1,323,1,84,1,345,1,158,1,325,Z5,285,1,286,1,140,1,23,1,93,Z2,35,Z6,346,1,344,1,277,1,84,1,347,1,158,1,278,Z5,289,1,286,1,104,1,23,1,97,Z2,23,Z6,326,1,327,1,322,1,146,1,328,1,197,1,278,Z5,277,1,278,1,84,Z5,104,2,23,Z6,338,1,348,1,294,1,146,1,339,1,248,1,297,Z5,294,1,295,1,112,Z5,112,1,57,Z2,11,1,338,1,339,1,337,1,146,1,339,1,158,1,295,Z5,294,1,297,1,146,Z5,112,Z2,57,Z6,349,1,339,1,294,1,146,1,350,1,158,1,297,1,57,Z3,297,1,112,Z5,118,2,47,1,11,384,63,1,351,1,352,1,353,1,112,1,354,1,299,1,325,Z5,355,1,356,1,93,Z2,234,1,177,1,35,Z6,333,1,172,1,294,1,112,1,334,1,240,1,295,Z5,172,1,357,1,112,Z2,240,1,186,Z5,11,1,358,1,294,1,33,1,112,1,359,1,146,1,360,Z5,33,1,297,1,154,Z2,245,Z5,126,Z6,338,2,294,1,112,1,348,1,146,1,295,Z5,339,1,297,1,112,Z2,248,2,57,Z6,361,1,352,1,344,1,112,1,331,1,299,1,278,Z5,362,1,356,1,97,Z2,201,1,177,1,23,Z6,363,1,172,Z3,112,1,172,1,240,1,297,Z5,364,1,357,1,118,Z2,208,1,186,Z2,11,1,338,1,294,1,339,1,112,1,337,1,146,1,295,Z5,339,1,297,1,158,Z2,146,2,57,Z6,349,1,294,Z3,112,1,339,1,146,1,297,Z5,350,1,297,1,118,Z2,158,1,57,Z2,11,384,63,1,343,1,344,1,353,1,112,1,365,1,197,1,325,Z5,285,1,286,1,93,Z2,140,1,23,1,35,Z6,338,1,339,1,294,1,112,1,348,1,248,1,295,Z5,294,1,297,1,112,Z2,146,2,57,Z6,366,Z3,33,1,112,1,367,1,158,1,360,Z5,305,1,306,1,154,Z2,154,Z2,126,Z6,349,Z3,294,1,112,1,368,1,158,1,295,1,57,Z3,306,1,112,Z2,158,Z2,57,Z6,346,2,344,1,112,1,328,1,197,1,278,Z5,289,1,286,1,97,Z2,104,2,23,Z6,349,1,339,Z3,112,1,339,1,248,1,297,1,57,Z3,297,1,118,Z2,112,1,57,Z2,11,1,349,Z3,339,1,112,1,339,1,158,1,295,1,57,Z3,306,1,158,Z2,112,Z2,57,Z6,369,2,300,1,112,1,350,1,158,1,297,Z5,309,1,306,1,118,Z2,118,2,47,1,11,384,Z1,1,167,1,168,1,171,1,172,1,169,1,170,1,173,1,34,1,174,1,175,1,176,1,177,1,8,1,9,1,10,Z6,178,1,179,1,200,1,172,1,198,1,199,1,139,1,34,1,183,1,184,1,201,1,177,1,21,1,22,1,23,Z6,228,1,229,1,232,1,172,1,230,1,231,1,191,1,34,1,232,1,233,1,234,1,177,1,33,1,34,1,35,Z6,249,1,229,1,200,1,172,1,250,1,231,1,139,1,34,1,251,1,233,1,201,1,177,1,39,1,34,1,23,Z6,178,1,179,1,181,1,182,1,180,1,170,1,139,1,34,1,183,1,184,1,185,1,186,1,20,1,9,1,23,Z6,202,1,203,1,205,1,182,1,204,1,199,1,153,1,34,1,206,1,207,1,208,1,186,1,46,1,22,Z2,11,1,235,1,236,1,238,1,182,1,237,1,231,1,145,1,34,1,238,1,239,1,240,1,186,1,56,1,34,Z5,11,1,252,1,236,1,205,1,182,1,253,1,231,1,153,1,34,1,254,1,239,1,208,1,186,1,61,1,34,Z2,11,128,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,310,1,311,1,313,1,299,1,312,1,84,1,314,Z5,315,1,316,1,176,1,177,1,75,1,23,1,10,Z6,329,1,330,1,331,1,299,1,322,1,146,1,278,Z5,331,1,332,1,201,1,177,1,84,Z5,23,Z6,351,1,352,1,354,1,299,1,353,1,112,1,325,Z5,355,1,356,1,234,1,177,1,93,Z2,35,Z6,361,1,352,1,331,1,299,1,344,1,112,1,278,Z5,362,1,356,1,201,1,177,1,97,Z2,23,Z6,317,2,318,1,240,1,277,1,84,1,278,Z5,319,1,320,1,185,1,186,1,104,2,23,Z6,333,1,334,1,172,1,240,1,294,1,146,1,297,Z5,172,1,335,1,208,1,186,1,112,1,57,Z2,11,1,333,1,172,1,334,1,240,1,294,1,112,1,295,Z5,172,1,357,1,240,1,186,1,112,Z2,57,Z6,363,2,172,1,240,Z3,112,1,297,Z5,364,1,357,1,208,1,186,1,118,2,47,1,11,128,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,187,1,188,1,190,1,56,1,189,1,170,1,191,1,34,1,192,1,83,1,193,Z5,32,1,9,1,35,Z6,209,1,210,1,144,1,56,1,210,1,199,1,145,1,34,1,211,1,111,1,146,Z5,55,1,22,Z5,11,1,241,1,237,1,243,1,56,1,242,1,231,1,244,1,34,1,243,1,145,1,245,Z5,125,1,34,1,126,Z6,246,1,237,1,144,1,56,1,255,1,231,1,145,1,34,1,247,1,145,1,146,Z5,130,1,34,Z5,11,1,194,1,188,1,195,1,56,1,180,1,170,1,139,1,34,1,196,1,83,1,197,Z5,20,1,9,1,23,Z6,212,1,210,1,157,1,56,1,204,1,199,1,153,1,34,1,213,1,111,1,158,Z5,46,1,22,Z2,11,1,246,1,237,1,247,1,56,1,237,1,231,1,145,1,34,1,247,1,145,1,248,Z5,56,1,34,Z5,11,1,256,1,237,1,157,1,56,1,253,1,231,1,153,1,34,1,257,1,145,1,158,Z5,61,1,34,Z2,11,384,63,1,321,1,322,1,324,1,146,1,323,1,84,1,325,Z5,323,1,278,1,193,Z5,140,1,23,1,35,Z6,336,2,337,1,146,1,337,1,146,1,295,Z5,337,1,295,1,146,Z5,146,2,57,Z6,358,1,294,1,359,1,146,1,33,1,112,1,360,Z5,33,1,297,1,245,Z5,154,Z2,126,Z6,338,1,294,1,337,1,146,1,339,1,112,1,295,Z5,339,1,297,1,146,Z5,158,Z2,57,Z6,326,1,322,1,327,1,146,1,277,1,84,1,278,Z5,328,1,278,1,197,Z5,104,2,23,Z6,338,1,337,1,339,1,146,1,294,1,146,1,297,Z5,339,1,295,1,158,Z5,112,1,57,Z2,11,1,338,1,294,1,348,1,146,1,294,1,112,1,295,Z5,339,1,297,1,248,Z5,112,Z2,57,Z6,349,1,294,1,339,1,146,Z3,112,1,297,Z5,350,1,297,1,158,Z5,118,2,47,1,11,384,Z1,1,370,1,371,1,372,1,373,1,372,1,373,1,374,Z2,375,1,376,1,176,1,177,1,176,1,177,1,10,Z6,377,1,378,1,379,1,373,1,380,1,208,1,286,Z2,381,1,382,1,201,1,177,1,185,1,186,1,23,Z6,351,1,352,1,355,1,373,1,353,1,112,1,383,Z2,354,1,332,1,234,1,177,1,193,Z5,35,Z6,361,1,352,1,379,1,373,1,344,1,112,1,286,Z2,384,1,332,1,201,1,177,1,197,Z5,23,Z6,377,1,378,1,380,1,208,1,379,1,373,1,286,Z2,381,1,382,1,185,1,186,1,201,1,177,1,23,Z6,385,1,386,1,387,1,208,1,387,1,208,1,306,Z2,386,1,388,1,208,1,186,1,208,1,186,Z2,11,1,333,2,172,1,208,1,294,1,112,1,297,Z2,334,1,335,1,240,1,186,1,146,2,57,Z6,363,1,172,1,387,1,208,Z3,112,1,306,Z2,389,1,335,1,208,1,186,1,158,1,57,Z2,11,128,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,390,1,391,1,372,1,373,1,392,1,97,1,374,Z2,315,1,316,1,176,1,177,1,75,1,23,1,10,Z6,361,1,393,1,379,1,373,1,344,1,158,1,286,Z2,331,1,332,1,201,1,177,1,84,Z5,23,Z6,394,1,395,1,355,1,373,1,396,1,118,1,383,Z2,355,1,356,1,234,1,177,1,93,Z2,35,Z6,397,1,395,1,379,1,373,1,398,1,118,1,286,Z2,362,1,356,1,201,1,177,1,97,Z2,23,Z6,399,1,400,1,380,1,208,1,289,1,97,1,286,Z2,319,1,320,1,185,1,186,1,104,2,23,Z6,363,1,389,1,387,1,208,Z3,158,1,306,Z2,172,1,335,1,208,1,186,1,112,1,57,Z2,11,1,363,1,364,1,172,1,208,Z3,118,1,297,Z2,172,1,357,1,240,1,186,1,112,Z2,57,Z6,401,1,364,1,387,1,208,1,309,1,118,1,306,Z2,364,1,357,1,208,1,186,1,118,2,47,1,11,128,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,4,Z4,132,63,1,351,1,352,1,353,1,112,1,355,1,373,1,383,Z2,354,1,332,1,193,Z5,234,1,177,1,35,Z6,333,1,172,1,294,1,112,1,172,1,208,1,297,Z2,334,1,335,1,146,Z5,240,1,186,Z5,11,1,358,1,294,1,33,1,112,1,33,1,112,1,402,Z2,359,1,295,1,245,Z5,245,Z5,126,Z6,338,2,294,1,112,1,339,1,112,1,297,Z2,348,1,295,1,146,Z5,248,2,57,Z6,361,1,352,1,344,1,112,1,379,1,373,1,286,Z2,384,1,332,1,197,Z5,201,1,177,1,23,Z6,363,1,172,Z3,112,1,387,1,208,1,306,Z2,389,1,335,1,158,Z5,208,1,186,Z2,11,1,338,1,294,1,339,1,112,1,294,1,112,1,297,Z2,348,1,295,1,248,Z5,146,2,57,Z6,349,1,294,Z3,112,Z3,112,1,306,Z2,368,1,295,1,158,Z5,158,1,57,Z2,11,384,63,1,343,1,344,1,353,1,112,1,403,1,97,1,383,Z2,323,1,278,1,193,Z5,140,1,23,1,35,Z6,338,1,339,1,294,1,112,1,339,1,158,1,297,Z2,337,1,295,1,146,Z5,146,2,57,Z6,366,Z3,33,1,112,1,404,1,118,1,402,Z2,33,1,297,1,245,Z5,154,Z2,126,Z6,349,Z3,294,1,112,1,350,1,118,1,297,Z2,339,1,297,1,146,Z5,158,Z2,57,Z6,346,2,344,1,112,1,289,1,97,1,286,Z2,328,1,278,1,197,Z5,104,2,23,Z6,349,1,339,Z3,112,Z3,158,1,306,Z2,339,1,295,1,158,Z5,112,1,57,Z2,11,1,349,Z3,339,1,112,Z3,118,1,297,Z2,339,1,297,1,248,Z5,112,Z2,57,Z6,369,2,300,1,112,1,309,1,118,1,306,Z2,350,1,297,1,158,Z5,118,2,47,1,11,384,Z1,1,214,1,215,1,216,1,39,1,169,1,170,1,173,1,34,1,73,1,74,1,75,1,23,1,8,1,9,1,10,Z6,223,1,224,1,161,1,39,1,198,1,199,1,139,1,34,1,102,1,103,1,104,1,23,1,21,1,22,1,23,Z6,258,1,250,1,259,1,39,1,230,1,231,1,191,1,34,1,138,1,139,1,140,1,23,1,33,1,34,1,35,Z6,262,1,250,1,161,1,39,1,250,1,231,1,139,1,34,1,161,1,139,1,104,1,23,1,39,1,34,1,23,Z6,194,1,217,1,195,1,130,1,180,1,170,1,139,1,34,1,82,1,83,1,84,Z5,20,1,9,1,23,Z6,212,1,225,1,157,1,130,1,204,1,199,1,153,1,34,1,110,1,111,1,112,Z5,46,1,22,Z2,11,1,246,1,255,1,247,1,130,1,237,1,231,1,145,1,34,1,144,1,145,1,146,Z5,56,1,34,Z5,11,1,256,1,255,1,157,1,130,1,253,1,231,1,153,1,34,1,157,1,145,1,112,Z5,61,1,34,Z2,11,384,63,1,340,1,341,1,342,1,197,1,312,1,84,1,314,Z5,270,1,271,1,75,1,23,1,75,1,23,1,10,Z6,326,1,327,1,328,1,197,1,322,1,146,1,278,Z5,277,1,278,1,104,1,23,1,84,Z5,23,Z6,343,1,344,1,365,1,197,1,353,1,112,1,325,Z5,285,1,286,1,140,1,23,1,93,Z2,35,Z6,346,1,344,1,328,1,197,1,344,1,112,1,278,Z5,289,1,286,1,104,1,23,1,97,Z2,23,Z6,326,2,327,1,248,1,277,1,84,1,278,Z5,277,1,278,1,84,Z5,104,2,23,Z6,338,1,348,1,339,1,248,1,294,1,146,1,297,Z5,294,1,295,1,112,Z5,112,1,57,Z2,11,1,338,1,339,1,348,1,248,1,294,1,112,1,295,Z5,294,1,297,1,146,Z5,112,Z2,57,Z6,349,2,339,1,248,Z3,112,1,297,1,57,Z3,297,1,112,Z5,118,2,47,1,11,384,63,1,218,1,219,1,220,1,61,1,189,1,170,1,191,1,34,1,91,1,92,1,93,Z2,32,1,9,1,35,Z6,212,1,226,1,157,1,61,1,210,1,199,1,145,1,34,1,110,1,114,1,112,Z2,55,1,22,Z5,11,1,260,1,253,1,261,1,61,1,242,1,231,1,244,1,34,1,152,1,153,1,154,Z2,125,1,34,1,126,Z6,256,1,253,1,157,1,61,1,255,1,231,1,145,1,34,1,157,1,153,1,112,Z2,130,1,34,Z5,11,1,221,1,219,1,222,1,61,1,180,1,170,1,139,1,34,1,96,1,92,1,97,Z2,20,1,9,1,23,Z6,227,1,226,1,165,1,61,1,204,1,199,1,153,1,34,1,117,1,114,1,118,Z2,46,1,22,Z2,11,1,256,1,253,1,257,1,61,1,237,1,231,1,145,1,34,1,157,1,153,1,158,Z2,56,1,34,Z5,11,1,263,1,253,1,165,1,61,1,253,1,231,1,153,1,34,1,165,1,153,1,118,Z2,61,1,34,Z2,11,384,63,1,343,1,344,1,345,1,158,1,323,1,84,1,325,Z5,285,1,286,1,93,Z2,140,1,23,1,35,Z6,338,2,339,1,158,1,337,1,146,1,295,Z5,294,1,297,1,112,Z2,146,2,57,Z6,366,Z3,367,1,158,1,33,1,112,1,360,Z5,305,1,306,1,154,Z2,154,Z2,126,Z6,349,Z3,339,1,158,1,339,1,112,1,295,1,57,Z3,306,1,112,Z2,158,Z2,57,Z6,346,1,344,1,347,1,158,1,277,1,84,1,278,Z5,289,1,286,1,97,Z2,104,2,23,Z6,349,1,339,1,350,1,158,1,294,1,146,1,297,1,57,Z3,297,1,118,Z2,112,1,57,Z2,11,1,349,Z3,368,1,158,1,294,1,112,1,295,1,57,Z3,306,1,158,Z2,112,Z2,57,Z6,369,Z3,350,1,158,Z3,112,1,297,Z5,309,1,306,1,118,Z2,118,2,47,1,11,384,Z1,1,390,1,391,1,392,1,97,1,372,1,373,1,374,Z2,315,1,316,1,75,1,23,1,176,1,177,1,10,Z6,399,1,400,1,289,1,97,1,380,1,208,1,286,Z2,319,1,320,1,104,1,23,1,185,1,186,1,23,Z6,343,1,344,1,403,1,97,1,353,1,112,1,383,Z2,323,1,278,1,140,1,23,1,193,Z5,35,Z6,346,1,344,1,289,1,97,1,344,1,112,1,286,Z2,328,1,278,1,104,1,23,1,197,Z5,23,Z6,361,1,393,1,344,1,158,1,379,1,373,1,286,Z2,331,1,332,1,84,Z5,201,1,177,1,23,Z6,363,1,389,Z3,158,1,387,1,208,1,306,Z2,172,1,335,1,112,Z5,208,1,186,Z2,11,1,338,2,339,1,158,1,294,1,112,1,297,Z2,337,1,295,1,146,Z5,146,2,57,Z6,349,1,339,Z3,158,Z3,112,1,306,Z2,339,1,295,1,112,Z5,158,1,57,Z2,11,384,63,1,405,1,406,1,392,1,97,1,392,1,97,1,374,Z2,270,1,271,1,75,1,23,1,75,1,23,1,10,Z6,346,1,347,1,289,1,97,1,344,1,158,1,286,Z2,277,1,278,1,104,1,23,1,84,Z5,23,Z6,407,1,398,1,403,1,97,1,396,1,118,1,383,Z2,285,1,286,1,140,1,23,1,93,Z2,35,Z6,408,1,398,1,289,1,97,1,398,1,118,1,286,Z2,289,1,286,1,104,1,23,1,97,Z2,23,Z6,346,1,347,1,344,1,158,1,289,1,97,1,286,Z2,277,1,278,1,84,Z5,104,2,23,Z6,349,1,368,Z3,158,Z3,158,1,306,Z2,294,1,295,1,112,Z5,112,1,57,Z2,11,1,349,1,350,1,339,1,158,Z3,118,1,297,Z2,294,1,297,1,146,Z5,112,Z2,57,Z6,369,1,350,Z3,158,1,309,1,118,1,306,Z2,300,1,297,1,112,Z5,118,2,47,1,11,384,63,1,394,1,395,1,396,1,118,1,355,1,373,1,383,Z2,355,1,356,1,93,Z2,234,1,177,1,35,Z6,363,1,364,Z3,118,1,172,1,208,1,297,Z2,172,1,357,1,112,Z2,240,1,186,Z5,11,1,366,Z3,404,1,118,1,33,1,112,1,402,Z2,33,1,297,1,154,Z2,245,Z5,126,Z6,349,2,300,1,118,1,339,1,112,1,297,Z2,339,1,297,1,112,Z2,248,2,57,Z6,397,1,395,1,398,1,118,1,379,1,373,1,286,Z2,362,1,356,1,97,Z2,201,1,177,1,23,Z6,401,1,364,1,309,1,118,1,387,1,208,1,306,Z2,364,1,357,1,118,Z2,208,1,186,Z2,11,1,349,Z3,350,1,118,1,294,1,112,1,297,Z2,339,1,297,1,158,Z2,146,2,57,Z6,369,Z3,309,1,118,Z3,112,1,306,Z2,350,1,297,1,118,Z2,158,1,57,Z2,11,384,63,1,407,1,398,1,396,1,118,1,403,1,97,1,383,Z2,285,1,286,1,93,Z2,140,1,23,1,35,Z6,349,1,350,Z3,118,1,339,1,158,1,297,Z2,294,1,297,1,112,Z2,146,2,57,Z6,409,1,309,1,404,1,118,1,404,1,118,1,402,Z2,305,1,306,1,154,Z2,154,Z2,126,Z6,369,1,309,Z3,118,1,350,1,118,1,297,Z2,300,1,306,1,112,Z2,158,Z2,57,Z6,408,2,398,1,118,1,289,1,97,1,286,Z2,289,1,286,1,97,Z2,104,2,23,Z6,369,1,350,1,309,1,118,Z3,158,1,306,Z2,300,1,297,1,118,Z2,112,1,57,Z2,11,1,369,1,309,1,350,1,118,Z3,118,1,297,Z2,300,1,306,1,158,Z2,112,Z2,57,Z6,410,2,309,1,118,1,309,1,118,1,306,Z2,309,1,306,1,118,Z2,118,2,47,1,11,384,Z1};
double precalc_type_area[65536];
struct t_circle {
int x;
int y;
bool is_small;
};
struct t_grid {
int x;
int y;
int type;
};
t_circle circles[200];
t_grid grid_stats[3200];
int grid_stats_count = 0;
//int checklist[200];
int n, m, ks, kl;
//根据ks,kl等4个参数的取值连续的读取一组数据
void read_data_set() {
int i, j;
//memset(&circles, 0, 200*sizeof(t_circle));
for (i=0; i<ks; i++) {
cin >> circles[i].x >> circles[i].y;
circles[i].is_small = true;
}
for (i=ks; i<ks+kl; i++) {
cin >> circles[i].x >> circles[i].y;
circles[i].is_small = false;
}
}
void add_one_stats(int x, int y, int plus_type) {
if (x<0 || x>m-1 || y<0 || y>n-1) return;
int index = -1;
for (int i=0; i<grid_stats_count; i++) {
if (grid_stats[i].x==x && grid_stats[i].y==y) {
index = i;
break;
}
}
if (index == -1) {
index = grid_stats_count++;
grid_stats[index].x = x;
grid_stats[index].y = y;
}
grid_stats[index].type |= plus_type;
}
//对各个方格进行统计,最后对每个方格做一个列表,列表中包括的是所有进入了该方格的圆形
void do_grid_stats() {
int i, j, k;
//清除上次统计的结果
grid_stats_count = 0;
memset(&grid_stats, 0, 3200*sizeof(t_grid));
//处理小圆的部分
for (i=0; i<ks; i++) {
int tx=circles[i].x, ty=circles[i].y;
add_one_stats(tx-1, ty-1, 1);
add_one_stats(tx, ty-1, 2);
add_one_stats(tx-1, ty, 4);
add_one_stats(tx, ty, 8);
}
//处理大圆的部分
for (i=ks; i<ks+kl; i++) {
int tx=circles[i].x, ty=circles[i].y;
add_one_stats(tx-1, ty-2, 16);
add_one_stats(tx, ty-2, 32);
add_one_stats(tx-2, ty-1, 64);
add_one_stats(tx-1, ty-1, 128);
add_one_stats(tx, ty-1, 256);
add_one_stats(tx+1, ty-1, 512);
add_one_stats(tx-2, ty, 1024);
add_one_stats(tx-1, ty, 2048);
add_one_stats(tx, ty, 4096);
add_one_stats(tx+1, ty, 8192);
add_one_stats(tx-1, ty+1, 16384);
add_one_stats(tx, ty+1, 32768);
}
}
double calc_area() {
//cout << grid_stats_count << endl;
double area=0.0;
for (int i=0; i<grid_stats_count; i++) {
area += precalc_type_area[grid_stats[i].type];
}
area += m*n - grid_stats_count;
return area;
}
double calc_one_set() {
read_data_set();
do_grid_stats();
return calc_area();
}
int main(void) {
//初始化precalc_type_area数组
int count = 0;
for (int i=0; i<precalc_zip_size; i++) {
for (int j=0; j<precalc_zip[i*2]; j++) {
precalc_type_area[count++] = key_value[(int)precalc_zip[i*2+1]];
}
}
//循环逐组读取数据进行计算和输出
for (;;) {
cin >> n >> m >> ks >> kl;
if (n==0 && m==0 && ks==0 && kl==0) break;
double result = calc_one_set();
printf("%.2f\n", result);
}
return 0;
}