답안 #163883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163883 2019-11-16T01:10:03 Z arnold518 Fences (JOI18_fences) C++14
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 100;

struct Line
{
	int x1, y1, x2, y2;
};

int N, C;
Line line[MAXN+10];
double ans;

int main()
{
	int i, j;
	scanf("%d%d", &N, &C);
	for(i=1; i<=N; i++) scanf("%d%d%d%d", &line[i].x1, &line[i].y1, &line[i].x2, &line[i].y2);

	ans=C*8;

	if(line[1].x1==C && line[1].x2==C) ans=min(ans, (double)C*8-min(C, max(line[1].y1, line[1].y2))-max(-C, min(line[1].y1, line[1].y2)));
	if(line[1].y1==C && line[1].y2==C) ans=min(ans, (double)C*8-min(C, max(line[1].x1, line[1].x2))-max(-C, min(line[1].x1, line[1].x2)));

	if(line[1].x1==-C && line[1].x2==-C) ans=min(ans, (double)C*8-min(C, max(line[1].y1, line[1].y2))-max(-C, min(line[1].y1, line[1].y2)));
	if(line[1].y1==-C && line[1].y2==-C) ans=min(ans, (double)C*8-min(C, max(line[1].x1, line[1].x2))-max(-C, min(line[1].x1, line[1].x2)));
	printf("%.10f", ans);
}

Compilation message

fences.cpp: In function 'int main()':
fences.cpp:21:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
fences.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &C);
  ~~~~~^~~~~~~~~~~~~~~~
fences.cpp:23:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%d%d%d%d", &line[i].x1, &line[i].y1, &line[i].x2, &line[i].y2);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -