Submission #1327906

#TimeUsernameProblemLanguageResultExecution timeMemory
1327906Zone_zonee라멘 (JOI14_ramen)C++20
50 / 100
1 ms332 KiB
#include "ramen.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> adj[410];
void Ramen(int N) {
  int mx = 0, mn = 0;
  for(int i = 1; i < N; ++i){
    if(Compare(mx, i) == -1){
      adj[i].push_back(mx);
      // cerr << "dbg : " << i << ' ' << mx << '\n';
      mx = i;
    }else{
      adj[mx].push_back(i);
      // cerr << "dbg : " << mx << ' ' << i << '\n';
    }
  }
  queue<int> q;
  q.push(mx);
  vector<int> leaves;
  while(!q.empty()){
    int u = q.front(); q.pop();
    cerr << u << ' ';
    bool leaf = 1;
    for(auto v : adj[u]){
      leaf = 0;
      q.push(v);
    }
    if(leaf) leaves.push_back(u);
  }
  mn = leaves.front();
  for(int i = 1; i < leaves.size(); ++i){
    if(Compare(mn, leaves[i]) == 1){
      mn = leaves[i];
    }
  }
  Answer(mn, mx);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...