Submission #1244108
Source Code Expand
#include <iostream> #include <fstream> #include <vector> #include <string> #include <algorithm> #include <time.h> #include <sys/timeb.h> using namespace std; int get_time(string r) { struct timeb rawtime; ftime(&rawtime); static int ms = rawtime.millitm; static unsigned long s = rawtime.time; int out_ms = rawtime.millitm - ms; unsigned long out_s = rawtime.time - s; if (out_ms < 0) { out_ms += 1000; out_s -= 1; } ms = rawtime.millitm; s = rawtime.time; int total = 1000*out_s+out_ms; cout<<r<<": "<<total<<"ms"<<endl; return total; } bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } int main(int argc, char *argv[]) { // get_time("begin"); long beMod = 10e9+7; int N; int a, b; vector<pair<int, int>> all; cin >> N; for (int i = 0; i < N; i++) cin>>a, all.emplace_back(a, 1); for (int i = 0; i < N; i++) cin>>b, all.emplace_back(b, -1); sort(all.begin(), all.end()); vector<long> f(100001); //factorial f[0] = 1; for (int i = 1; i <= 100000; i++) f[i] = (f[i - 1] * i) % beMod; // for (int i = 0; i < 2 * N; i++) cout<<all[i].first<<endl; long cnt = 0, res = 1; for(int i=0;i<all.size();i++){ if(all[i].second==1){ if(cnt < 0) res = res * -cnt % mod; cnt++; } else{ if(cnt > 0) res = res * cnt % mod; cnt--; } } cout<<res<<endl; // get_time("end"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | elfredayao |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1448 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main(int, char**)’: ./Main.cpp:60:35: error: ‘mod’ was not declared in this scope if(cnt < 0) res = res * -cnt % mod; ^ ./Main.cpp:64:34: error: ‘mod’ was not declared in this scope if(cnt > 0) res = res * cnt % mod; ^