Submission #3882556
Source Code Expand
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
const int MX = 100055;
const int MM = 1000000007;
struct BIT{
int t[MX];
int read(int x){
int r = 0;
while(x) r = (r + t[x]) % MM, x -= x&-x;
return r;
}
void update(int x, int v){
while(x < MX) t[x] = (t[x] + v) % MM, x += x&-x;
}
} tree;
vector<int> X, Y;
int N, M;
int main()
{
scanf("%d%d", &N, &M);
for(int i = 1; i <= N; i++){
int a;
scanf("%d", &a);
X.push_back(a);
}
for(int i = 1; i <= M; i++){
int a;
scanf("%d", &a);
Y.push_back(a);
}
vector<pii> D;
vector<int> Cy;
for(int x : X){
int y = lower_bound(Y.begin(), Y.end(), x) - Y.begin();
if(y == 0 || y == Y.size()) continue;
D.emplace_back(x - Y[y-1], Y[y] - x);
Cy.push_back(Y[y] - x);
}
sort(D.begin(), D.end());
D.resize(unique(D.begin(), D.end()) - D.begin());
sort(Cy.begin(), Cy.end());
for(pii &c : D){
c.second = upper_bound(Cy.begin(), Cy.end(), c.second) - Cy.begin() + 1;
}
sort(D.begin(), D.end(), [](pii l, pii r){
return l.first < r.first || l.first == r.first && l.second > r.second;
});
tree.update(1, 1);
for(int i = 0, j = 0; i < D.size(); i = j){
for(; j < D.size(); j++){
if(D[i].first != D[j].first) break;
tree.update(D[j].second, tree.read(D[j].second-1));
}
}
printf("%d\n", tree.read(MX-1));
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Robots and Exits |
| User | zigui |
| Language | C++14 (GCC 5.4.1) |
| Score | 900 |
| Code Size | 2566 Byte |
| Status | AC |
| Exec Time | 145 ms |
| Memory | 3060 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:74:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &N, &M);
^
./Main.cpp:77:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a);
^
./Main.cpp:82:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a);
^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 900 / 900 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00.txt | AC | 1 ms | 256 KiB |
| 0_01.txt | AC | 1 ms | 256 KiB |
| 0_02.txt | AC | 1 ms | 256 KiB |
| 0_03.txt | AC | 1 ms | 256 KiB |
| 0_04.txt | AC | 1 ms | 256 KiB |
| 1_00.txt | AC | 1 ms | 256 KiB |
| 1_01.txt | AC | 1 ms | 256 KiB |
| 1_02.txt | AC | 30 ms | 2804 KiB |
| 1_03.txt | AC | 26 ms | 1528 KiB |
| 1_04.txt | AC | 22 ms | 1404 KiB |
| 1_05.txt | AC | 18 ms | 1148 KiB |
| 1_06.txt | AC | 18 ms | 1148 KiB |
| 1_07.txt | AC | 19 ms | 1148 KiB |
| 1_08.txt | AC | 34 ms | 2932 KiB |
| 1_09.txt | AC | 35 ms | 2932 KiB |
| 1_10.txt | AC | 35 ms | 2932 KiB |
| 1_11.txt | AC | 34 ms | 2932 KiB |
| 1_12.txt | AC | 34 ms | 2804 KiB |
| 1_13.txt | AC | 35 ms | 2932 KiB |
| 1_14.txt | AC | 34 ms | 2804 KiB |
| 1_15.txt | AC | 34 ms | 2932 KiB |
| 1_16.txt | AC | 64 ms | 3060 KiB |
| 1_17.txt | AC | 64 ms | 3060 KiB |
| 1_18.txt | AC | 64 ms | 3060 KiB |
| 1_19.txt | AC | 64 ms | 3060 KiB |
| 1_20.txt | AC | 63 ms | 3060 KiB |
| 1_21.txt | AC | 64 ms | 3060 KiB |
| 1_22.txt | AC | 64 ms | 3060 KiB |
| 1_23.txt | AC | 64 ms | 3060 KiB |
| 1_24.txt | AC | 13 ms | 892 KiB |
| 1_25.txt | AC | 13 ms | 892 KiB |
| 1_26.txt | AC | 13 ms | 892 KiB |
| 1_27.txt | AC | 13 ms | 892 KiB |
| 1_28.txt | AC | 23 ms | 1912 KiB |
| 1_29.txt | AC | 15 ms | 892 KiB |
| 1_30.txt | AC | 14 ms | 892 KiB |
| 1_31.txt | AC | 27 ms | 2420 KiB |
| 1_32.txt | AC | 19 ms | 1272 KiB |
| 1_33.txt | AC | 27 ms | 1784 KiB |
| 1_34.txt | AC | 27 ms | 1784 KiB |
| 1_35.txt | AC | 33 ms | 2548 KiB |
| 1_36.txt | AC | 20 ms | 1272 KiB |
| 1_37.txt | AC | 26 ms | 1912 KiB |
| 1_38.txt | AC | 25 ms | 1912 KiB |
| 1_39.txt | AC | 22 ms | 1656 KiB |
| 1_40.txt | AC | 30 ms | 2292 KiB |
| 1_41.txt | AC | 35 ms | 2676 KiB |
| 1_42.txt | AC | 33 ms | 2548 KiB |
| 1_43.txt | AC | 31 ms | 2420 KiB |
| 1_44.txt | AC | 41 ms | 2676 KiB |
| 1_45.txt | AC | 41 ms | 2676 KiB |
| 1_46.txt | AC | 41 ms | 2676 KiB |
| 1_47.txt | AC | 41 ms | 2676 KiB |
| 1_48.txt | AC | 46 ms | 2676 KiB |
| 1_49.txt | AC | 46 ms | 2676 KiB |
| 1_50.txt | AC | 46 ms | 2676 KiB |
| 1_51.txt | AC | 46 ms | 2676 KiB |
| 1_52.txt | AC | 50 ms | 2804 KiB |
| 1_53.txt | AC | 50 ms | 2804 KiB |
| 1_54.txt | AC | 145 ms | 2804 KiB |
| 1_55.txt | AC | 51 ms | 2804 KiB |