Submission #1244100
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 = 1000000007; 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(), cmp); 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 curr = -1, sum = 0, res = 1; for (int i = 0; i < 2 * N; i++) { sum += all[i].second; if (sum == 0) { res = (res * f[(i - curr) / 2]) % beMod; curr = i; } } 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 | 1434 Byte |
Status | WA |
Exec Time | 103 ms |
Memory | 2544 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 | 65 ms | 2164 KB |
001.txt | WA | 24 ms | 1528 KB |
002.txt | WA | 32 ms | 1656 KB |
003.txt | WA | 36 ms | 1652 KB |
004.txt | WA | 91 ms | 2420 KB |
005.txt | WA | 102 ms | 2544 KB |
006.txt | WA | 103 ms | 2544 KB |
007.txt | WA | 101 ms | 2544 KB |
008.txt | WA | 102 ms | 2544 KB |
009.txt | WA | 102 ms | 2544 KB |
010.txt | AC | 103 ms | 2544 KB |
011.txt | AC | 102 ms | 2544 KB |
example0.txt | AC | 2 ms | 1024 KB |
example1.txt | AC | 2 ms | 1024 KB |