-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b33a8a
commit 29b3904
Showing
26 changed files
with
2,525 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/*Read the problem carefully before starting to work on it*/ | ||
#include <bits/stdc++.h> | ||
//#include <boost/multiprecision/cpp_int.hpp> | ||
//using namespace boost::multiprecision; | ||
//#include <ext/pb_ds/assoc_container.hpp> | ||
//#include <ext/pb_ds/tree_policy.hpp> | ||
using namespace std; | ||
//using namespace __gnu_pbds; | ||
|
||
typedef long long ll; | ||
|
||
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;} | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mp(x,y) make_pair(x,y) | ||
#define mod 1000000007 | ||
|
||
double PI=3.1415926535897932384626; | ||
|
||
//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;} | ||
|
||
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost; | ||
|
||
#define fi first | ||
#define se second | ||
|
||
#define SSIZE 300005 | ||
#define N 10 | ||
|
||
ll grid[SSIZE][N]; | ||
|
||
ll n,m; | ||
|
||
int main() | ||
{ | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
cin>>n>>m; | ||
for(ll i=1;i<=n;i++) | ||
{ | ||
for(ll j=1;j<=m;j++) | ||
{ | ||
cin>>grid[i][j]; | ||
} | ||
} | ||
ll a=1,b=1; | ||
ll lo=0,hi=1e9; | ||
while(lo<hi) | ||
{ | ||
ll mid=lo+(hi-lo+1)/2; | ||
set<ll>tmp; | ||
map<ll,ll>mm; | ||
for(ll i=1;i<=n;i++) | ||
{ | ||
ll mask=0; | ||
for(ll j=1;j<=m;j++) | ||
{ | ||
if(grid[i][j]>=mid) | ||
{ | ||
mask+=(1LL<<(j-1)); | ||
} | ||
} | ||
tmp.insert(mask); | ||
mm[mask]=i; | ||
} | ||
vector<ll>tmp1; | ||
for(auto &x:tmp) | ||
{ | ||
tmp1.eb(x); | ||
} | ||
ll fl=0; | ||
for(ll i=0;i<tmp1.size();i++) | ||
{ | ||
for(ll j=i;j<tmp1.size();j++) | ||
{ | ||
ll val=tmp1[i]|tmp1[j]; | ||
if(val==((1LL<<m)-1)) | ||
{ | ||
a=mm[tmp1[i]]; | ||
b=mm[tmp1[j]]; | ||
fl=1; | ||
break; | ||
} | ||
} | ||
if(fl) | ||
break; | ||
} | ||
if(fl==0) | ||
{ | ||
hi=mid-1; | ||
} | ||
else | ||
{ | ||
lo=mid; | ||
} | ||
} | ||
cout<<a<<" "<<b; | ||
return 0; | ||
} | ||
|
||
|
||
//252908XL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/*Read the problem carefully before starting to work on it*/ | ||
#include <bits/stdc++.h> | ||
//#include <boost/multiprecision/cpp_int.hpp> | ||
//using namespace boost::multiprecision; | ||
//#include <ext/pb_ds/assoc_container.hpp> | ||
//#include <ext/pb_ds/tree_policy.hpp> | ||
using namespace std; | ||
//using namespace __gnu_pbds; | ||
|
||
typedef long long ll; | ||
|
||
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;} | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mp(x,y) make_pair(x,y) | ||
#define mod 1000000007 | ||
|
||
double PI=3.1415926535897932384626; | ||
|
||
//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;} | ||
|
||
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost; | ||
|
||
#define fi first | ||
#define se second | ||
#define SSIZE 200005 | ||
|
||
ll n; | ||
|
||
set< pair<ll,ll> >dedges; | ||
vector< vector<ll> >adj(SSIZE); | ||
vector<ll>visited(SSIZE,0); | ||
|
||
ll totalulti=0; | ||
ll dp[SSIZE]; | ||
|
||
ll ans=LLONG_MAX; | ||
|
||
void dfs(ll curr) | ||
{ | ||
visited[curr]=1; | ||
for(auto &nei:adj[curr]) | ||
{ | ||
if(visited[nei]) | ||
continue; | ||
if(dedges.find(mp(curr,nei))==dedges.end()) | ||
{ | ||
totalulti++; | ||
} | ||
dfs(nei); | ||
} | ||
} | ||
|
||
void dfs1(ll curr,ll ccount,ll ulti) | ||
{ | ||
visited[curr]=1; | ||
dp[curr]=totalulti-2*ulti+ccount; | ||
ans=min(ans,dp[curr]); | ||
for(auto &nei:adj[curr]) | ||
{ | ||
if(visited[nei]) | ||
continue; | ||
ll hehe=0; | ||
if(dedges.find(mp(curr,nei))==dedges.end()) | ||
{ | ||
hehe=1; | ||
} | ||
dfs1(nei,ccount+1,ulti+hehe); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
cin>>n; | ||
for(ll i=0;i<(n-1);i++) | ||
{ | ||
ll a,b; | ||
cin>>a>>b; | ||
dedges.insert(mp(a,b)); | ||
adj[a].eb(b); | ||
adj[b].eb(a); | ||
} | ||
dfs(1); | ||
for(ll i=0;i<=n;i++) | ||
{ | ||
visited[i]=0; | ||
} | ||
dfs1(1,0,0); | ||
cout<<ans<<"\n"; | ||
for(ll i=1;i<=n;i++) | ||
{ | ||
if(dp[i]==ans) | ||
{ | ||
cout<<i<<" "; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
//252908XL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/*Read the problem carefully before starting to work on it*/ | ||
#include <bits/stdc++.h> | ||
//#include <boost/multiprecision/cpp_int.hpp> | ||
//using namespace boost::multiprecision; | ||
//#include <ext/pb_ds/assoc_container.hpp> | ||
//#include <ext/pb_ds/tree_policy.hpp> | ||
using namespace std; | ||
//using namespace __gnu_pbds; | ||
|
||
typedef long long ll; | ||
|
||
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;} | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mp(x,y) make_pair(x,y) | ||
#define mod 1000000007 | ||
|
||
double PI=3.1415926535897932384626; | ||
|
||
//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;} | ||
|
||
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost; | ||
|
||
#define fi first | ||
#define se second | ||
|
||
#define SSIZE 100005 | ||
|
||
ll n; | ||
|
||
vector< vector<ll> >adj(SSIZE); | ||
vector< ll >visited(SSIZE,0); | ||
|
||
ll val[SSIZE]; | ||
ll target[SSIZE]; | ||
|
||
vector<ll>ans; | ||
|
||
void dfs(ll curr,ll ev_lvl,ll odd_lvl,ll lvl) | ||
{ | ||
visited[curr]=1; | ||
ll lvl1=lvl%2; | ||
if(lvl1) | ||
{ | ||
val[curr]^=odd_lvl; | ||
} | ||
else | ||
{ | ||
val[curr]^=ev_lvl; | ||
} | ||
if(val[curr]!=target[curr]) | ||
{ | ||
ans.eb(curr); | ||
val[curr]=target[curr]; | ||
if(lvl1) | ||
{ | ||
odd_lvl^=1; | ||
} | ||
else | ||
{ | ||
ev_lvl^=1; | ||
} | ||
} | ||
for(auto &nei:adj[curr]) | ||
{ | ||
if(!visited[nei]) | ||
dfs(nei,ev_lvl,odd_lvl,lvl+1); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
cin>>n; | ||
for(ll i=0;i<(n-1);i++) | ||
{ | ||
ll a,b; | ||
cin>>a>>b; | ||
adj[a].eb(b); | ||
adj[b].eb(a); | ||
} | ||
for(ll i=1;i<=n;i++) | ||
{ | ||
cin>>val[i]; | ||
} | ||
for(ll j=1;j<=n;j++) | ||
{ | ||
cin>>target[j]; | ||
} | ||
dfs(1,0,0,0); | ||
cout<<ans.size()<<endl; | ||
for(auto &cont:ans) | ||
{ | ||
cout<<cont<<"\n"; | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
//252908XL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*Read the problem carefully before starting to work on it*/ | ||
#include <bits/stdc++.h> | ||
//#include <boost/multiprecision/cpp_int.hpp> | ||
//using namespace boost::multiprecision; | ||
//#include <ext/pb_ds/assoc_container.hpp> | ||
//#include <ext/pb_ds/tree_policy.hpp> | ||
using namespace std; | ||
//using namespace __gnu_pbds; | ||
|
||
typedef long long ll; | ||
|
||
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;} | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mp(x,y) make_pair(x,y) | ||
#define mod 1000000007 | ||
|
||
double PI=3.1415926535897932384626; | ||
|
||
//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;} | ||
|
||
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost; | ||
|
||
#define fi first | ||
#define se second | ||
|
||
int main() | ||
{ | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
ll m,n; | ||
cin>>m>>n; | ||
double ans=0; | ||
for(ll i=1;i<=m;i++) | ||
{ | ||
double tem=(double)i/(double)m; | ||
double tem1=(double)(i-1)/(double)m; | ||
tem=pow(tem,n); | ||
tem1=pow(tem1,n); | ||
tem-=tem1; | ||
tem*=i; | ||
ans+=tem; | ||
} | ||
cout<<fixed<<setprecision(8); | ||
cout<<ans; | ||
return 0; | ||
} | ||
|
||
|
||
//252908XL |
Oops, something went wrong.