# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890413 | Muhammad_Aneeq | Sails (IOI07_sails) | C++17 | 1063 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
بسم الله الرحمن الرحيم
Author:
(:Muhammad Aneeq:)
*/
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define int long long
int const N=1e5+10;
int n;
int ans=1e15+10;
int vis[N]={};
set<set<int>>d[N];
void dfs(int x,int val=0)
{
if (x==n)
{
ans=min(ans,val);
return;
}
for (auto j:d[x])
{
int z=0;
for (auto k:j)
{
z+=vis[k];
vis[k]++;
}
dfs(x+1,val+z);
for (auto k:j)
vis[k]--;
}
}
set<int>cur;
void dfs1(int i,int h,int k)
{
if (cur.size()==k)
{
d[i].insert(cur);
return;
}
for (int j=0;j<h;j++)
{
if (!vis[j])
{
vis[j]=1;
cur.insert(j);
dfs1(i,h,k);
vis[j]=0;
cur.erase(j);
}
}
}
inline void solve()
{
cin>>n;
for (int i=0;i<n;i++)
{
int h,k;
cin>>h>>k;
dfs1(i,h,k);
}
dfs(0);
cout<<ans<<endl;
}
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |