제출 #135484

#제출 시각아이디문제언어결과실행 시간메모리
135484eohomegrownappsMeetings (JOI19_meetings)C++14
29 / 100
2524 ms7592 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; //Query(int a, int b, int c) //Bridge(int first, int second) //edges from 0 to n-1 typedef long long ll; ll acns = 100000000; ll bcns = 10000; unordered_map<ll,int> querymap; int n; int squery(int a, int b, int c){ //cout<<"query "<<a<<" "<<b<<" "<<c<<endl; if (a>b){ swap(a,b); } if (b>c){ swap(b,c); } if (a>b){ swap(a,b); } if (b>c){ swap(b,c); } ll q = a*acns+b*bcns+c; auto f = querymap.find(q); if (f==querymap.end()){ return querymap[q]=Query(a,b,c); } else { return (*f).second; } } int sortstart, sortend; bool sfunction(int a, int b){ return (squery(sortstart,a,b)==a); } void solverecursive(int start, vector<int> &arrayUsing){ /*cout<<"===="<<endl; for (int i : arrayUsing){ cout<<i<<" "; }cout<<endl;*/ int end = arrayUsing[0]; deque<int> row; row.push_back(start); row.push_back(end); vector<vector<int> > children(n); for (int i = 1; i<arrayUsing.size(); i++){ int node = squery(start,end,arrayUsing[i]); if (node==start){ row.push_front(arrayUsing[i]); start=arrayUsing[i]; } else if (node==end){ row.push_back(arrayUsing[i]); end=arrayUsing[i]; } else if (node==arrayUsing[i]){ row[row.size()-1]=node; row.push_back(end); } else { children[node].push_back(arrayUsing[i]); } } /*for (int r : row){ cout<<r<<" "; }cout<<endl;*/ //sort if (row.size()>3){ auto b = next(row.begin(),1); auto e = prev(row.end(),1); sortstart=start; sortend=end; sort(b,e,sfunction); } for (int i = 0; i<row.size()-1; i++){ //cout<<"bridge "<<min(row[i],row[i+1])<<" "<<max(row[i],row[i+1])<<endl; Bridge(min(row[i],row[i+1]),max(row[i],row[i+1])); if (children[row[i]].size()==0){ continue; } else if (children[row[i]].size()==1){ //cout<<"bridge "<<min(row[i],children[row[i]][0])<<" "<<max(row[i],children[row[i]][0])<<endl; Bridge(min(row[i],children[row[i]][0]),max(row[i],children[row[i]][0])); } else { solverecursive(row[i],children[row[i]]); } }//add case where i=row.size()-1 } void Solve(int N) { n = N; vector<int> arrayUsing; arrayUsing.resize(n-1,0); for (int i = 1; i<n; i++){ arrayUsing[i-1]=i; } solverecursive(0,arrayUsing); }

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

meetings.cpp: In function 'void solverecursive(int, std::vector<int>&)':
meetings.cpp:50:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i<arrayUsing.size(); i++){
                  ~^~~~~~~~~~~~~~~~~~
meetings.cpp:76:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i<row.size()-1; i++){
                  ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...