[HDU] [2022] Audition for the Female Lead

Problem Description

Loading...

Problem Analysis

For this problem, after thinking it over, I didn’t create an array
I used three variables to record the number with the largest absolute value
and made the comparison that way

The side story is that I wrote this problem yesterday but kept failing to debug it
When I looked at it today, I quickly found that the current variable num had been named m
which made the loop always empty

From this you can see……
Sometimes after using your brain a lot, rest is still necessary
(Though today seems even more slacking off than yesterday)
Or maybe it’s like~
When you can’t remember something for a moment, put it aside first
and then maybe at some point an idea will suddenly come to you~

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<stdio.h>
int main() {
	int m,n;
	while(scanf("%d %d",&m,&n)!=EOF) {
		int x=1,y=1,num=0;
		for(int i=1; i<=m; i++) {
			for(int j=1; j<=n; j++) {
				int t;
				scanf("%d",&t);
				if(t<0) {
					if(num<0&&t<num) {
						num=t;
						x=j;
						y=i;
					} else if(num>=0&&-t>num) {
						num=t;
						x=j;
						y=i;
					}
				} else {
					if(num>=0&&t>num) {
						num=t;
						x=j;
						y=i;
					} else if(num<0&&-t<num) {
						num=t;
						x=j;
						y=i;
					}
				}
			}
		}
		printf("%d %d %d\n",y,x,num);
	}
	return 0;
}

Problem link:HDU [2022] Audition for the Leading Actress

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...