Advertisement
Vince14

Combination Lock

Apr 19th, 2025
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4. #include <cstring>
  5. #include <algorithm>
  6. #include <cmath>
  7. #include <regex>
  8. #include <vector>
  9. #include <set>
  10. #include <map>
  11. #include <stack>
  12. #include <queue>
  13. #include <deque>
  14. #include <unordered_map>
  15. #include <numeric>
  16. #include <iomanip>
  17. using namespace std;
  18. #define pii pair<int, int>
  19. #define ll long long
  20. #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
  21. #define mp(x1, x2) ( make_pair(x1, x2) )
  22. const int dx[4] = {1, 0, 0, -1}, dy[4] = {0, 1, -1, 0};
  23. const int dl[2] = {1, -1};
  24. const int MOD = 100000007;
  25. const int MAXN = 100;
  26.  
  27. int n;
  28. int x, y, z;
  29. int a, b, c;
  30. int ans = 0;
  31.  
  32. bool check(int xx, int yy) {
  33.     if (abs(xx - yy) <= 2) return true;
  34.     if (abs(xx - yy) == n - 1 or abs(xx -yy) == n - 2) return true;
  35.     return false;
  36. }
  37. int main(){
  38.     FAST;
  39.     //freopen("combo.in", "r", stdin);
  40.     //freopen("combo.out", "w", stdout);
  41.     cin >> n;
  42.     cin >> x >> y >> z;
  43.     cin >> a >> b >> c;
  44.     for (int i = 1; i <= n; i++) {
  45.         for (int j = 1; j <= n; j++) {
  46.             for (int k = 1; k <= n; k++) {
  47.                 if ((check(x, i) and check(y, j) and check(z, k)) or
  48.                     (check(a, i) and check(b, j) and check(c, k))) {
  49.                     // cout << i << " " << j << " " << k << "\n";
  50.                     ans++;
  51.                 }
  52.             }
  53.         }
  54.     }
  55.     cout << ans << "\n";
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement