제출 #1194597

#제출 시각아이디문제언어결과실행 시간메모리
1194597hengliao마술쇼 (APIO24_show)C++20
0 / 100
1 ms328 KiB
#include "Alice.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define vll vector<ll> #define pll pair<ll, ll> typedef long long ll; // you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables. // you had better not use the same global variables in function Alice() and in function Bob(). vector<pair<int,int>> Alice(){ ll n=5000; ll tar=setN(n); vector<pair<int, int>> re; ll f=tar/n+1; ll s=tar%n+1; cout<<"f: "<<f<<'\n'; cout<<"s: "<<s<<'\n'; if(f==s){ for(ll i=1;i<=n;i++){ if(i==tar) continue; re.pb({i, tar}); } return re; } ll pt=1; for(ll rep=0;rep<n/2-1;rep++){ while(pt==f || pt==s) pt++; re.pb({pt, f}); pt++; } for(ll rep=0;rep<n/2-1;rep++){ while(pt==f || pt==s) pt++; re.pb({pt, s}); pt++; } re.pb({f, s}); return re; }
#include "Bob.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define vll vector<ll> #define pll pair<ll, ll> typedef long long ll; // you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables. // you had better not use the same global variables in function Alice() and in function Bob(). long long Bob(std::vector<std::pair<int,int>> V){ // add your code here ll n=5000; vll cnt(n+1); for(auto &[x, y]:V){ cnt[x]++; cnt[y]++; } vll con; for(ll i=1;i<=n;i++){ if(cnt[i]>1){ con.pb(i); } } if(con.size()==1){ ll tep=con[0]; tep--; return tep*n+tep; } ll pt=n; while(pt==con[0] || pt==con[1]) pt--; bool good=1; for(auto &[x, y]:V){ if((x==con[0] && y==pt) || (y==con[0] && x==pt)){ good=0; } } if(!good){ swap(con[0], con[1]); } con[0]--; con[1]--; return con[0]*n+con[1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...