Submission #1419811
Source Code Expand
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; void solve(){ int N; cin >> N; vector< pair<int,int> > pos(2*N); for(int i=0;i<N;++i){ cin >> pos[i].first; pos[i].second = 0; } for(int i=0;i<N;++i){ cin >> pos[i+N].first; pos[i+N].second = 1; } // sort(pos.begin(), pos.end() ); vector<int> A(2,0),need(2,0); vector<LL> fact(N+1,0); fact[1] = 1; for(LL i=2;i<=N;++i){ fact[2] = (fact[i-1]*i) % MOD; } LL ans = 1; int prev = pos[0].second; ++A[prev]; for(int i=1;i<2*N;++i){ int kind = pos[i].second; if( need[kind] ){ --need[kind]; continue; } if( prev == kind ){ A[ kind ]++; }else{ ans = ( ans * fact[ A[prev] ] ) % MOD; need[(kind+1)%2] += A[prev]; A[prev] = 0; prev = kind; } } cout << ans << endl; } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | akarin55 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1941 Byte |
Status | WA |
Exec Time | 38 ms |
Memory | 2560 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | WA | 23 ms | 1664 KB |
001.txt | WA | 9 ms | 768 KB |
002.txt | WA | 12 ms | 1024 KB |
003.txt | WA | 13 ms | 1024 KB |
004.txt | WA | 34 ms | 2304 KB |
005.txt | WA | 38 ms | 2560 KB |
006.txt | WA | 38 ms | 2560 KB |
007.txt | WA | 38 ms | 2560 KB |
008.txt | WA | 38 ms | 2560 KB |
009.txt | WA | 38 ms | 2560 KB |
010.txt | WA | 37 ms | 2560 KB |
011.txt | WA | 38 ms | 2560 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |