Created
October 20, 2012 15:33
-
-
Save Abreto/3923592 to your computer and use it in GitHub Desktop.
NOIP2011提高组
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
| /* NOIP2011 Day1 - carpet.c */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main(void) | |
| { | |
| int i = 0, j = 0; | |
| int n = 0; | |
| int *a = NULL, *b = NULL, *g = NULL, *k = NULL; | |
| int x = 0, y = 0; | |
| scanf("%d", &n); | |
| a = (int *)malloc( n * sizeof(int) ); | |
| b = (int *)malloc( n * sizeof(int) ); | |
| g = (int *)malloc( n * sizeof(int) ); | |
| k = (int *)malloc( n * sizeof(int) ); | |
| for(i = 0;i < n;i++) | |
| scanf("%d %d %d %d", a+i, b+i, g+i, k+i); | |
| scanf("%d %d", &x, &y); | |
| for(i = n;i > 0;i--) | |
| { | |
| if( | |
| (x >= *(a+i-1)) && (x <= *(a+i-1)+*(g+i-1) ) | |
| && (y >= *(b+i-1)) && (y <= *(b+i-1)+*(k+i-1)) | |
| ) | |
| { | |
| return !printf("%d\n", i); | |
| } | |
| } | |
| return !printf("-1\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment