제출 #1127072

#제출 시각아이디문제언어결과실행 시간메모리
1127072RequiemFence (CEOI08_fence)C++20
50 / 100
5 ms324 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #define MOD 1000000007 #define inf 1e18 #define fi first #define se second #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define sz(a) ((int)(a).size()) #define endl '\n' #define pi 3.14159265359 #define TASKNAME "fence" using namespace std; template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } typedef pair<int,int> ii; typedef pair<int,ii> iii; typedef vector<int> vi; const int MAXN = 102; int dist[MAXN][MAXN]; const int costFence = 20; const int costTree = 111; struct point{ int x, y; point(int _x = 0, int _y = 0){ x = _x; y = _y; } point operator + (const point &other){ return point(x + other.x, y + other.y); } point operator - (const point &other){ return point(x - other.x, y - other.y); } }; int ccw(point a, point b, point c){ b = b - a; c = c - a; return b.x * c.y - c.x * b.y; } vector<point> holes; vector<point> trees; int n, m; main() { fast; if (fopen(TASKNAME".inp","r")){ freopen(TASKNAME".inp","r",stdin); freopen(TASKNAME".out","w",stdout); } cin >> n >> m; FOR(i, 1, n){ int x, y; cin >> x >> y; holes.pb(point(x, y)); } FOR(i, 1, m){ int x, y; cin >> x >> y; trees.pb(point(x, y)); } memset(dist, 0x3f, sizeof(dist)); FOR(i, 0, n - 1){ FOR(j, 0, n - 1){ if (i == j) continue; dist[i][j] = costFence; FOR(k, 0, m - 1){ if (ccw(holes[i], holes[j], trees[k]) < 0) dist[i][j] += costTree; } } } FOR(k, 0, n - 1){ FOR(i, 0, n - 1){ FOR(j, 0, n - 1){ minimize(dist[i][j], dist[i][k] + dist[k][j]); } } } int ans = inf; FOR(i, 0, n - 1){ minimize(ans, dist[i][i]); } cout << ans << endl; } /** Warning: Đọc sai đề??? Cận lmao Code imple thiếu case nào không. Limit. **/

컴파일 시 표준 에러 (stderr) 메시지

fence.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main()
      | ^~~~
fence.cpp: In function 'int main()':
fence.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen(TASKNAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
fence.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(TASKNAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...