Submission #2172590
Source Code Expand
#include <bits/stdc++.h> //#include <math.h> using namespace std; #define INF 1.1e9 #define LINF 1.1e18 #define FOR(i,a,b) for (int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define pb push_back #define pf push_front #define fi first #define se second #define BIT(x,n) bitset<n>(x) #define PI 3.14159265358979323846 typedef long long ll; typedef pair<int,int> P; //typedef pair<int,P> PP; //----------------------------------------------------------------------------- int n,tmp; vector<P> vec; const int MOD=1e9+7; int main() { cin.tie(0); ios::sync_with_stdio(false); cin>>n; REP(i,2*n) { cin>>tmp; vec.pb(P(tmp,(int)(i>=n))); } ll ans=1; int cnt_a=0,cnt_b=0; for(auto v:vec) { if(v.se==0) { if(cnt_b==0) cnt_a++; else (ans*=cnt_b)%=MOD,cnt_b=1; } else { if(cnt_a==0) cnt_b++; else (ans*=cnt_a)%=MOD,cnt_a=1; } //cout<<cnt_a<<' '<<cnt_b<<' '<<ans<<endl; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | moko_freedom |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1023 Byte |
Status | WA |
Exec Time | 26 ms |
Memory | 2420 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 | 14 ms | 1400 KB |
001.txt | WA | 6 ms | 892 KB |
002.txt | WA | 8 ms | 892 KB |
003.txt | WA | 9 ms | 1400 KB |
004.txt | WA | 21 ms | 2420 KB |
005.txt | WA | 26 ms | 2420 KB |
006.txt | WA | 23 ms | 2420 KB |
007.txt | WA | 23 ms | 2420 KB |
008.txt | WA | 23 ms | 2420 KB |
009.txt | WA | 23 ms | 2420 KB |
010.txt | WA | 23 ms | 2420 KB |
011.txt | WA | 23 ms | 2420 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | WA | 1 ms | 256 KB |