Submission #919911

#TimeUsernameProblemLanguageResultExecution timeMemory
919911CyberCowAmusement Park (CEOI19_amusementpark)C++17
42 / 100
3026 ms171124 KiB
#include <random> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <chrono> #define fr first #define sc second #define ad push_back using namespace std; using ll = long long; mt19937 rnd(348502); const ll N = 20; vector<pair<int,int>> v[N]; int tex[N]; int uxx[N][N]; ll mod = 998244353; void solve() { int n, i, j, m, x, y; cin >> n >> m; for ( i = 0; i < m; i++) { cin >> x >> y; v[x].push_back({ y, i }); v[y].push_back({ x, i }); uxx[x][y] = 1; } vector<int> pereb; for ( i = 1; i <= n; i++) { pereb.push_back(i); } set<ll> ka; ll ans = 0; int bj = 1; do { //cout << bj++ << ' '; for ( i = 0; i < pereb.size(); i++) { tex[pereb[i]] = i; } ll gum = 0, pox = 0; for ( i = 0; i < pereb.size(); i++) { for (auto to : v[pereb[i]]) { if ((tex[pereb[i]] > tex[to.first] && uxx[to.first][pereb[i]] == 0)||(tex[pereb[i]] < tex[to.first] && uxx[pereb[i]][to.first] == 0)) { gum++; pox |= (1LL << to.second); } } } if (ka.find(pox) == ka.end()) { ans = (ans + gum / 2) % mod; ka.insert(pox); } } while (next_permutation(pereb.begin(), pereb.end())); cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll tt = 1; //cin >> tt; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

amusementpark.cpp: In function 'void solve()':
amusementpark.cpp:56:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for ( i = 0; i < pereb.size(); i++)
      |                      ~~^~~~~~~~~~~~~~
amusementpark.cpp:61:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for ( i = 0; i < pereb.size(); i++)
      |                      ~~^~~~~~~~~~~~~~
amusementpark.cpp:36:15: warning: unused variable 'j' [-Wunused-variable]
   36 |     int n, i, j, m, x, y;
      |               ^
amusementpark.cpp:52:9: warning: unused variable 'bj' [-Wunused-variable]
   52 |     int bj = 1;
      |         ^~
#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...