답안 #894946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894946 2023-12-29T09:30:24 Z vjudge1 Mergers (JOI19_mergers) C++17
0 / 100
237 ms 262144 KB
//In His Name
#include <bits/stdc++.h>
//#pragma GCC optimization("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
const int maxn = 14 , MOD = 1e9 + 7;
const ll INF = 1e18;

int n , val[2*maxn];
vector<string> v;

void Solve(string& a, int l, int r) {
    if(l == r) v.pb(a);
    else {
        for (int i = l; i <= r; i++) {
            swap(a[l], a[i]);
            Solve(a, l + 1, r);
            swap(a[l], a[i]);
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1 ; i <= n ; i++){
        int x;
        cin >> x;
        val[x] = 1;
    }
    int ans = 0;
    string s = "";
    for(int i = 1 ; i <= 2*n ; i++) s += to_string(i);
    Solve(s , 0 , s.size()-1);
    for(string j : v){
        string x = "";
        for(int i = 0 ; i < j.size() ; i++) x +=  to_string(((j[i] - '0' + 1)/2));
        for(int i = 1 ; i <= n ; i++){
            bool mark[15];
            memset(mark , 0 , sizeof mark);
            for(int k = 0 ; k < x.size() ; k++) {
                if (!mark[x[k] - '0']) x[k]--, mark[x[k] - '0' +1] = true;
                if(x[k] < '0') x[k] = '0';
            }
        }
        for(int i = 0 ; i < x.size() ; i++) {
            if (x[i] > '0' and val[i + 1] == 0) {
                ans--;
                break;
            }
           if(x[i] <= '0' and val[i + 1] == 1){
               ans--;
               break;
           }
        }
        ans++;
        ans %= MOD;
    }
    cout << ans ;
}

Compilation message

mergers.cpp: In function 'int32_t main()':
mergers.cpp:47:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int i = 0 ; i < j.size() ; i++) x +=  to_string(((j[i] - '0' + 1)/2));
      |                         ~~^~~~~~~~~~
mergers.cpp:51:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for(int k = 0 ; k < x.size() ; k++) {
      |                             ~~^~~~~~~~~~
mergers.cpp:56:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for(int i = 0 ; i < x.size() ; i++) {
      |                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -