제출 #898305

#제출 시각아이디문제언어결과실행 시간메모리
8983058pete8Meetings (JOI19_meetings)C++17
0 / 100
353 ms1280 KiB
#include "meetings.h" #include <cstdio> #include <cstdlib> #include <algorithm> #include <set> #include <utility> #include <vector> #include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<unordered_map> #include <queue> #include<cstring> #include<float.h> #include<limits.h> #include <cassert> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> //gcd(a,b) #include<bitset> using namespace std; #define ll long long #define f first #define endl "\n" #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-loops") const int mxn=2e3; using namespace std;/* namespace { const int MAX_N = 2000; const int MAX_CALLS = 100000; void WrongAnswer(int code) { printf("Wrong Answer [%d]\n", code); exit(0); } int N, num_calls; std::vector<int> graph[MAX_N]; std::set<std::pair<int, int>> edges, edges_reported; int weight[MAX_N]; bool Visit(int p, int e, int rt = -1) { if (p == e) { ++weight[p]; return true; } for (int q : graph[p]) { if (q != rt) { if (Visit(q, e, p)) { ++weight[p]; return true; } } } return false; } } // namespace int Query(int u, int v, int w) { if (!(0 <= u && u <= N - 1 && 0 <= v && v <= N - 1 && 0 <= w && w <= N - 1 && u != v && u != w && v != w)) { WrongAnswer(1); } if (++num_calls > MAX_CALLS) { WrongAnswer(2); } std::fill(weight, weight + N, 0); Visit(u, v); Visit(u, w); Visit(v, w); for (int x = 0; x < N; ++x) { if (weight[x] == 3) { return x; } } printf("Error: the input may be invalid\n"); exit(0); } void Bridge(int u, int v) { if (!(0 <= u && u < v && v <= N - 1)) { WrongAnswer(3); } if (!(edges.count(std::make_pair(u, v)) >= 1)) { cout<<u<<" "<<v<<'\n'; WrongAnswer(4); } if (!(edges_reported.count(std::make_pair(u, v)) == 0)) { WrongAnswer(5); } edges_reported.insert(std::make_pair(u, v)); }*/ set<int>adj[mxn+10]; bool vis[mxn+10]; void dfs(int root,int cur,int node,int parent){ int k=(root==cur?cur:Query(root,node,cur)); if(k==node){ adj[parent].erase(adj[parent].find(cur)); adj[parent].insert(node); adj[node].insert(cur); vis[node]=true; return; } if(k==cur){ for(auto i:adj[cur]){ if(Query(i,cur,node)!=cur){ dfs(root,i,node,cur); return; } } adj[cur].insert(node); vis[node]=true; return; } dfs(root,root,k,-1); dfs(root,k,node,-1); vis[node]=true; } void Solve(int a){ int root=Query(0,1,2); vis[0]=vis[1]=vis[2]=true; for(int i=0;i<3;i++)if(i!=root)adj[root].insert(i); for(int i=3;i<a;i++){ if(!vis[i])dfs(root,root,i,-1); } for(int i=0;i<a;i++){ for(auto j:adj[i]){ Bridge(min(i,j),max(i,j)); } } }/* int main() { if (scanf("%d", &N) != 1) { fprintf(stderr, "Error while reading input\n"); exit(1); } for (int i = 0; i < N - 1; ++i) { int u, v; if (scanf("%d%d", &u, &v) != 2) { fprintf(stderr, "Error while reading input\n"); exit(1); } graph[u].push_back(v); graph[v].push_back(u); edges.insert(std::make_pair(min(u,v), max(u,v))); } num_calls = 0; Solve(N); if (edges_reported.size() != static_cast<size_t>(N - 1)) { WrongAnswer(6); } printf("Accepted: %d\n", num_calls); return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...