Created
May 12, 2015 17:25
-
-
Save balamark/ff5dfb4b2c0c26cca8d6 to your computer and use it in GitHub Desktop.
retrospect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int ans=55; | |
| for(int tryc=0;tryc<N;++tryc){ | |
| for(int cntr: vc){ // here I try to squeeze other ducks toward this center duck | |
| int t=0; //tmp ans | |
| printf("Try col @ %d, center @ %d\n", tryc, cntr); | |
| for(int row: vc){ | |
| int up=cntr-1, down=cntr+1; | |
| for(int c=0;c<N;++c) if(grid[row][c]=='o'){ | |
| t += abs(c - tryc); | |
| //step toward center: | |
| if(row>cntr){ | |
| t += row-down; | |
| down += 1; | |
| } | |
| else if(row<cntr){ | |
| t += row-up; | |
| up += 1; | |
| } | |
| } | |
| } | |
| cout<<"="<<t<<endl; | |
| ans = min(ans, t); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment