Submission #1262847

#TimeUsernameProblemLanguageResultExecution timeMemory
1262847nimoxideA Huge Tower (CEOI10_tower)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 100; int n, d, a[MAXN]; long long dp[30][1 << 20], answer; vector<int> graph[MAXN]; void input(); void generateGraph(); void countLenNP(); int main() { input(); generateGraph(); countLenNP(); cout << answer % (1e9 + 7) << endl; } void input() { cin >> n >> d; for (int i = 0; i < n; i++) cin >> a[i]; } void generateGraph() { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (a[i] - a[j] >= -d) graph[i].push_back(j); } void countLenNP() { for (int v = 0; v < n; v++) dp[v][1 << v] = 1; for (int mask = 1; mask < (1 << n); mask++) for (int v = 0; v < n; v++) { if (!(mask & (1 << v))) continue; for (int u : graph[v]) { if (mask & (1 << u)) continue; dp[u][mask | (1 << u)] += dp[v][mask] % (1e9 + 7); dp[u][mask] %= (1e9 + 7); } } for (int mask = 1; mask < (1 << n); mask++) if (__builtin_popcount(mask) == n) for (int v = 0; v < n; v++) { answer += dp[v][mask]; answer %= (1e9 + 7); } }

Compilation message (stderr)

tower.cpp: In function 'int main()':
tower.cpp:18:24: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   18 |         cout << answer % (1e9 + 7) << endl;
      |                 ~~~~~~ ^ ~~~~~~~~~
      |                 |             |
      |                 long long int double
tower.cpp: In function 'void countLenNP()':
tower.cpp:45:55: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   45 |                 dp[u][mask | (1 << u)] += dp[v][mask] % (1e9 + 7);
      |                                           ~~~~~~~~~~~ ^ ~~~~~~~~~
      |                                                     |        |
      |                                                     |        double
      |                                                     long long int
tower.cpp:46:29: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   46 |                 dp[u][mask] %= (1e9 + 7);
      |                 ~~~~~~~~~~~~^~~~~~~~~~~~
tower.cpp:46:29: note:   in evaluation of 'operator%=(long long int, double)'
tower.cpp:54:24: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   54 |                 answer %= (1e9 + 7);
      |                 ~~~~~~~^~~~~~~~~~~~
tower.cpp:54:24: note:   in evaluation of 'operator%=(long long int, double)'