Submission #528093

# Submission time Handle Problem Language Result Execution time Memory
528093 2022-02-19T08:31:40 Z kaxzert Amusement Park (CEOI19_amusementpark) C++17
0 / 100
1 ms 312 KB
/**
      ⚡⚡  ⚡⚡      ⚡⚡⚡     ⚡⚡  ⚡⚡  ⚡⚡⚡⚡⚡⚡   ⚡⚡⚡⚡⚡  ⚡⚡⚡⚡⚡⚡  ⚡⚡⚡⚡⚡⚡
      ⚡⚡ ⚡⚡      ⚡⚡⚡⚡     ⚡⚡⚡⚡      ⚡⚡      ⚡⚡       ⚡⚡    ⚡⚡  ⚡⚡⚡⚡⚡⚡
      ⚡⚡⚡⚡      ⚡⚡  ⚡⚡      ⚡⚡      ⚡⚡       ⚡⚡⚡⚡⚡   ⚡⚡⚡⚡⚡⚡     ⚡⚡
      ⚡⚡ ⚡⚡    ⚡⚡⚡⚡⚡⚡     ⚡⚡     ⚡⚡         ⚡⚡       ⚡⚡  ⚡⚡       ⚡⚡
      ⚡⚡  ⚡⚡  ⚡⚡     ⚡⚡  ⚡⚡ ⚡⚡  ⚡⚡⚡⚡⚡⚡  ⚡⚡⚡⚡⚡    ⚡⚡   ⚡⚡     ⚡⚡
**/

#include<bits/stdc++.h>

using namespace std;

#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl;
#define ll long long
#define db double
#define ldb long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define vt vector
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(i, a) for(auto &i : a)
#define sz(a) (int)a.size()
#define pi(a, b) pair<a, b>
#define fast ios::sync_with_stdio(false); cin.tie(0)

void setIO(string s) {
    if (sz(s) != 0) {
        freopen((s+".inp").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

void setIOusaco(string s) {
    if (sz(s) != 0) {
        freopen((s+".in").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

template<typename T, typename V>
bool ckmin(T &a, V b) {return (b < a)? a = b, true : false;}
template<typename T, typename V>
bool ckmax(T &a, V b) {return (b > a)? a = b, true : false;}

const int maxN = 20;
vt<int> ke[maxN];
const int oo = 998244353;

int main() {
    #ifndef TAP 
    setIO("");
    //setIOusaco("CEOI19_amusementpark");
    #endif

    fast;
    int n, m;
    cin >> n >> m;
    fto(i, 1, m) {
        int u, v;
        cin >> u >> v;
        ke[u].pb(v);
    }

    vt<int> a(n);
    iota(all(a), 0);

    int ans = 0;
    do {
        fto(i, 1, n) {
            trav(v, ke[i]) {
                if ((ans += (a[v-1]<a[i-1])) > oo) ans -= oo;
            }
        }
    } while(next_permutation(all(a)));

    cout << ans << '\n';

    return 0;
}

Compilation message

amusementpark.cpp: In function 'void setIO(std::string)':
amusementpark.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen((s+".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp: In function 'void setIOusaco(std::string)':
amusementpark.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen((s+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -