Daily questions day9 punch
Analysis
This question is an analog, two 0 ~ 128 (1 ~ 128 note not) the center point of the cycle enumeration square, a square boundary is determined, and then enumerate the number of cycles in public places like.
Time complexity <O (128 ² × 160 ²) = O (419430400) acceptable
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 128+10 using namespace std; inline int read() { int x=0; bool f=1; char c=getchar(); for(; !isdigit(c); c=getchar()) if(c=='-') f=0; for(; isdigit(c); c=getchar()) x=(x<<3)+(x<<1)+c-'0'; if(f) return x; return 0-x; } inline void write(int x) { if(x<0){putchar('-');x=-x;} if(x>9)write(x/10); putchar(x%10+'0'); } int d,n; int map[maxn][maxn]; int ans_num,ans_sum=-1; int main() { memset(map,0,sizeof(map)); d=read(); n=read(); for(int i=1;i<=n;i++) { int x=read(),y=read(),k=read(); map[x][y]=k; } for(int i=0;i<=128;i++) for(int j=0;j<=128;j++) { int xi=0,yi=0,xj=0,yj=0,cnt=0; if(i-d<0) xi=0; else xi=i-d; if(i+d>128) yi=128; else yi=i+d; if(j-d<0) xj=0; else xj=j-d; if(j+d>128) yj=128; else yj=j+d; for ( int a = x; it <= y; it ++ ) for ( int j = x; j <= vj; j ++ ) { cnt + = map [to] [j]; } If (cnt> ans_sum) { ans_sum = cnt; ans_num = 1 ; } Else if (cnt == ans_sum) ans_num ++ ; } Write (ans_num); printf ( " " ); Write (ans_sum); return 0; }
Please Gangster treatise(Anyway, I do not know what that means treatise)