# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
705789 | 2023-03-05T09:15:22 Z | Abito | Papričice (COCI20_papricice) | C++14 | 183 ms | 340 KB |
#include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define endl "\n" #define rip(i,a,b) for(ll i=a;i<=b;i++) #define in insert using namespace std; const ll M=998244353; vector<int> adj[205]; bool vis[205]; vector< pair< int , int> > v; int ans=INT_MAX; int cnt=0; set< pair< int ,int > > s; void dfs(int node){ vis[node]=1; cnt++; for(auto u : adj[node]){ if (vis[u]) continue; if (s.find({node,u})!=s.end() || s.find({u,node})!=s.end()) continue; dfs(u); } return ; } int32_t main(){ //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n; cin>>n; for(int i=1;i<=n-1;i++){ int x,y; cin>>x>>y; adj[x].pb(y); adj[y].pb(x); v.pb({x,y}); } for(int i=0;i<v.size();i++){ for(int j=0;j<v.size();j++){ if(i!=j){ int mx=-1,mi=INT_MAX; s.in(v[i]); s.in(v[j]); for(int i=1;i<=n;i++) vis[i]=0; for(int i=1;i<=n;i++){ cnt=0; if(vis[i]) continue; dfs(i); mi=min(mi,cnt); mx=max(mx,cnt); } s.clear(); ans=min(ans,mx-mi); } } } cout<<ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 183 ms | 300 KB | Output is correct |
2 | Correct | 180 ms | 296 KB | Output is correct |
3 | Correct | 148 ms | 332 KB | Output is correct |
4 | Correct | 166 ms | 292 KB | Output is correct |
5 | Correct | 169 ms | 292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 183 ms | 300 KB | Output is correct |
2 | Correct | 180 ms | 296 KB | Output is correct |
3 | Correct | 148 ms | 332 KB | Output is correct |
4 | Correct | 166 ms | 292 KB | Output is correct |
5 | Correct | 169 ms | 292 KB | Output is correct |
6 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 183 ms | 300 KB | Output is correct |
2 | Correct | 180 ms | 296 KB | Output is correct |
3 | Correct | 148 ms | 332 KB | Output is correct |
4 | Correct | 166 ms | 292 KB | Output is correct |
5 | Correct | 169 ms | 292 KB | Output is correct |
6 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
7 | Halted | 0 ms | 0 KB | - |