Submission #991663

#TimeUsernameProblemLanguageResultExecution timeMemory
991663De3b0oPresent (RMI21_present)C++14
8 / 100
2 ms604 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...