Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- USER: leomaster@in.gr
- LANG: C
- TASK: dimokritos
- */
- #include <stdio.h>
- #include <stdlib.h>
- int gps[1403][1403],*lntd,*lttd;
- FILE *iostr;
- int main() {
- int ps,dgt,mvs,vnx,vny;
- iostr = fopen("dimokritos.in", "r");
- fscanf(iostr, "%d", &dgt);
- lntd = (int *) malloc(dgt * sizeof (int));
- lttd = (int *) malloc(dgt * sizeof (int));
- for (ps = 0; ps < dgt; ps++) {
- fscanf(iostr, "%d %d", &lntd[ps], <td[ps]);
- }
- vnx = vny = 701;
- fscanf(iostr, "%d\n", &mvs);
- for (ps = 0; ps <= mvs; ps++) {
- if (ps > 0) {
- switch (getc(iostr)) {
- case 'U': vny++; break;
- case 'D': vny--; break;
- case 'R': vnx++; break;
- case 'L': vnx--; break;
- }
- }
- gps[vnx-1][vny-1]++; gps[vnx][vny]++; gps[vnx+1][vny+1]++;
- gps[vnx][vny-1]++; gps[vnx+1][vny]++; gps[vnx-1][vny+1]++;
- gps[vnx+1][vny-1]++; gps[vnx-1][vny]++; gps[vnx][vny+1]++;
- }
- fclose(iostr);
- iostr = fopen("dimokritos.out", "w");
- if (mvs > 0) {
- for (ps = 0; ps < dgt; ps++)
- if (gps[lntd[ps]+701][lttd[ps]+701] > 0)
- fprintf(iostr, "%d %d\n", ps+1, gps[ps[lntd]+701][ps[lttd]+701]);
- } else {
- fprintf(iostr, "-1\n");
- }
- fclose(iostr);
- free(lntd), free(lttd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement