제출 #865119

#제출 시각아이디문제언어결과실행 시간메모리
865119RequiemAmusement Park (CEOI19_amusementpark)C++17
42 / 100
3023 ms398236 KiB
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 998244353
#define INF 1e18
#define fi first
#define se second
#define endl "\n"
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) ((int)(a).size())
#define pi 3.14159265359
#define TASKNAME "amusepark"
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
const int MAXN = 3e2 + 9;
ii edge[MAXN];
int n,m,ans=0;
int pos[MAXN];
map<int,int> hashcode;
set<int> st;
main()
{
    fast;
  //   freopen(TASKNAME".inp","r",stdin);
  //   freopen(TASKNAME".out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>edge[i].fi>>edge[i].se;
    }
    int permutation[15];
    string s;
    iota(permutation+1,permutation+1+n,1);
    do{
        for(int i=1;i<=n;i++){
            pos[permutation[i]] = i;
        }
        int cost = 0;
        int code = 0;

        for(int i=1;i<=m;i++){
            if (pos[edge[i].fi] > pos[edge[i].se]) {
                cost++;
                code = code + (1LL<<(i-1));
            }
        }
        if (st.insert(code).se == true){
            ans = (ans + cost) % MOD;
            hashcode[code] = 1;
        }

    }while(next_permutation(permutation+1,permutation+1+n));
    cout<<ans<<endl;


}

컴파일 시 표준 에러 (stderr) 메시지

amusementpark.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main()
      | ^~~~
#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...