Submission #1127037

#TimeUsernameProblemLanguageResultExecution timeMemory
1127037RequiemAdriatic (CEOI13_adriatic)C++20
50 / 100
2100 ms110088 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 "bc" 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 = 2e5 + 9; int n; vector<int> g[MAXN]; int x[MAXN], y[MAXN], answer[MAXN]; int dist[5001][5001]; void bfs(int s, int dist[]){ queue<int> q; q.push(s); dist[s] = 0; while(!q.empty()){ int u = q.front(); answer[s] += dist[u]; q.pop(); for(auto &v: g[u]){ if (minimize(dist[v], dist[u] + 1)){ q.push(v); } } } } namespace subtask1{ bool check(){ return n <= 5000; } void solve(){ FOR(i, 1, n){ FOR(j, i + 1, n) { if ((x[i] < x[j] and y[i] < y[j]) or (x[i] > x[j] and y[i] > y[j])){ g[i].pb(j); g[j].pb(i); } } } memset(dist, 0x3f, sizeof(dist)); FOR(i, 1, n){ bfs(i, dist[i]); } FOR(i, 1, n){ cout << answer[i] << endl; } } } main() { fast; if (fopen(TASKNAME".inp","r")){ freopen(TASKNAME".inp","r",stdin); freopen(TASKNAME".out","w",stdout); } cin >> n; FOR(i, 1, n){ cin >>x[i] >> y[i]; } if (subtask1::check()) return subtask1::solve(), 0; } /** Warning: Đọc sai đề??? Cận lmao Code imple thiếu case nào không. Limit. **/

Compilation message (stderr)

adriatic.cpp:72:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   72 | main()
      | ^~~~
adriatic.cpp: In function 'int main()':
adriatic.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen(TASKNAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
adriatic.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         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...