# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
991663 |
2024-06-02T18:28:52 Z |
De3b0o |
Present (RMI21_present) |
C++14 |
|
2 ms |
604 KB |
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)
using namespace std;
ll fp(ll x , ll y)
{
if(y==0)
return 1;
ll z = fp(x,y/2);
if(y&1)
return z*z*x;
else
return z*z;
}
int sqrot(ll x)
{
int l = 0 , r = INT_MAX;
while(l<=r)
{
if(mid*mid>=x)
r=mid-1;
else
l=mid+1;
}
return r+1;
}
ll cel(ll x , ll y)
{
return x/y + bool(x%y);
}
string tb(ll x)
{
string s = "";
while(x>0)
{
if(x&1)
s+='1';
else
s+='0';
x/=2;
}
while(s.size()<60)
s+='0';
return s;
}
ll fb(string s)
{
ll x = 0;
ll c = 1;
for(int8_t i = 0 ; 60>i ; i++)
{
if(s[i]=='1')
x+=c;
c*=2;
}
return x;
}
set<vector<ll>> s;
ll gc[9][9];
bool cnt[9];
vector<vector<ll>> ans;
void solve(ll idx , vector<ll> e , ll mx)
{
if(idx==8)
{
bool g=1;
memset(cnt,0,sizeof(cnt));
for(auto it : e)
cnt[it]=1;
for(int i = 0 ; e.size()>i ; i++)
{
for(int j = i+1 ; e.size()>j ; j++)
{
if(cnt[gc[e[i]][e[j]]]==0)
g=0;
}
}
reverse(e.begin(),e.end());
if(g)
s.in(e);
return;
}
vector<ll> e2=e;
solve(idx+1,e2,mx);
for(int i = mx+1 ; 8>=i ; i++)
{
vector<ll> e1 = e;
e1.pb(i);
solve(idx+1,e1,i);
}
}
int main()
{
d3
ll t;
cin >> t;
for(int i = 1 ; 8>=i ; i++)
{
for(int j = 1 ; 8>=j ; j++)
gc[i][j]=__gcd(i,j);
}
solve(0,{},0);
vector<vector<ll>> v;
for(auto it : s)
v.pb(it);
sort(v.begin(),v.end());
for(auto it : v)
ans.pb(it);
while(t--)
{
ll k;
cin >> k;
cout << ans[k].size() << " ";
for(int i = ans[k].size()-1 ; i>=0 ; i--)
cout << ans[k][i] << " ";
lin
}
}
Compilation message
Main.cpp: In function 'void solve(long long int, std::vector<long long int>, long long int)':
Main.cpp:93:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
93 | for(int i = 0 ; e.size()>i ; i++)
| ~~~~~~~~^~
Main.cpp:95:39: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
95 | for(int j = i+1 ; e.size()>j ; j++)
| ~~~~~~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |