|
|
back to boardFor Admins! Something is wrong with your compiler! I am getting compilation error, but I CAN compile it? #include <fstream.h> #include <stdlib.h> #include <mem.h> //ifstream fin("square.dat"); short l,a,m, imp[100],size[100],x[100],y[100]; char f[10001]; short s[2][10001]; inline short min3(short a, short b, short c) { return a<b ? (a<c?a:c) : (b<c?b:c); } void trace(int r, int u) { int i,j,g; memset(f+1,1,l); for(i=0; i<m; i++) if(imp[i]>u && y[i]<=r && r<y[i]+size[i]) { g=x[i]+size[i]; for(j=x[i]; j<g; j++) f[j]=0; } } void find(int u) { int i,j,b1,b0; trace(1,u); if(a==1) for(i=1; i<=l; i++) { if(f[i]) {cout << u << endl; exit(0);} s[1][i]=0; } else for(i=1; i<=l; i++)s[1][i]=f[i]; for(j=2; j<=l; j++) { b1=j&1; b0=1-b1; s[b1][0]=0; trace(j,u); for(i=1; i<=l; i++) if(f[i]) { s[b1][i] = 1+min3(s[b1][i-1],s[b0][i],s[b0][i-1]); if(s[b1][i]==a) {cout << u << endl; exit(0);} } else s[b1][i] = 0; } } void main() { cin >> l >> a >> m; char z[101]={0,1}; for(int i=0; i<m; i++) {cin >> imp[i] >> size[i] >> x[i] >> y[i]; z[imp[i]]=1;} for(i=1; i<=100; i++) if(z[i]) find(i); cout << "IMPOSSIBLE" << endl; } |
|
|