Submission #968941

#TimeUsernameProblemLanguageResultExecution timeMemory
968941auslanderBeautiful row (IZhO12_beauty)C++17
0 / 100
1 ms348 KiB
#include <iostream> #include <algorithm> #include <math.h> #include <string> #include <iomanip> #include <queue> #include <stack> #include <deque> #include <set> #include <map> #include <vector> #include <iterator> using namespace std; typedef long long ll; typedef unsigned usg; #define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define multi int t; cin>>t; while(t--) solve() #define single solve(); return 0 #define ratdig(x) cout << fixed << setprecision(x); #define xfixdig(x) cout << setprecision(x); #define rev(x) reverse(x.begin(), x.end()) #define all(x) x.begin(), x.end() void yn(bool b) { if (b) { cout << "YES\n"; return; } cout << "NO\n"; } ll gcd(ll a, ll b) { if (a == 0) return b; if (b == 0) return a; return gcd(b % a, a); } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } string to2(ll a, ll n = -1) { string r = ""; for (ll i = 0; (1 << i) <= a; i++) { char c = (((1 << i) & a) != 0) + '0'; r += c; } if (a == 0) { r = "0"; } if (n != -1) { for (int i = 0; i < n - r.size(); i++) r += '0'; } rev(r); return r; } ll b2(ll a) { ll r = 0; for (ll i = 0; (1 << i) <= a; i++) { ll c = (((1 << i) & a) != 0); r += c; } return r; } ll b3(ll a, ll n = -1) { ll r = 0; ll y = 1; for (ll i = 0; y <= a; i++) { ll c = ((y & a) != 0); r += c; y *= 3; } return r; } ll binpow(ll a, ll b, ll mod = -1) { ll ans = 1; while (b) { if ((b & 1) == 1) { ans *= a; if (mod != -1) ans %= mod; } b >>= 1; a *= a; if (mod != -1) a %= mod; } return ans; } ll arr[25], a2[25], a3[25]; ll a[25]; void solve() { int m, n, i, j, k; cin >> n; for (i = 0; i < n; i++) { cin >> arr[i]; a[i] = i; a2[i] = b2(arr[i]); a3[i] = b3(arr[i]); } ll res = 0; do { for (i = 1; i < n; i++) { if (a2[a[i]] != a2[a[i - 1]] && a3[a[i]] != a3[a[i - 1]]) { res--; break; } } res++; } while (next_permutation(a, a + n)); cout << res; } int main() { speed; single; multi; return 0; }

Compilation message (stderr)

beauty.cpp: In function 'std::string to2(ll, ll)':
beauty.cpp:63:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   63 |   for (int i = 0; i < n - r.size(); i++)
      |                   ~~^~~~~~~~~~~~~~
beauty.cpp: In function 'void solve()':
beauty.cpp:120:6: warning: unused variable 'm' [-Wunused-variable]
  120 |  int m, n, i, j, k;
      |      ^
beauty.cpp:120:15: warning: unused variable 'j' [-Wunused-variable]
  120 |  int m, n, i, j, k;
      |               ^
beauty.cpp:120:18: warning: unused variable 'k' [-Wunused-variable]
  120 |  int m, n, i, j, k;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...