Submission #912331

# Submission time Handle Problem Language Result Execution time Memory
912331 2024-01-19T10:03:24 Z vjudge1 Wish (LMIO19_noras) C++17
0 / 100
2 ms 6492 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define ent "\n"

const int inf = (int)1e9 + 100;
const int maxn = 5e5 + 100;
const ll INF = (ll)1e18;
const int MOD = 1e9 + 7;
const int maxl = 62500;
const ll P = 31, T = 0;

ll n, r;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll d[maxn];

bool ok(ll x, ll y){
	return x * x + y * y <= r * r;
}

void test(){
	cin >> n >> r;
	vector<pii> v;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		cin >> c[i] >> d[i];
		c[i] -= a[i], d[i] -= b[i];
		if(d[i]){
			int l = inf, r;
			for(int j = 0; abs(a[i]) <= 10000 && abs(b[i]) <= 10000; j++, a[i] += c[i], b[i] += d[i]){
				if(ok(a[i], b[i])){
					if(l == inf){
						l = j;
					}
					r = j;
				}
			}
			if(l != inf){
				v.push_back({l, 1});
				v.push_back({r+1, -1});
			}
		} else{
			if(!c[i]) continue;
			int l = -(int)sqrt(r * r - b[i] * b[i]), r = -l;
			if(l <= a[i] && a[i] <= r){
				v.push_back({0, 1});
				if(c[i] > 0){
					v.push_back({(r - a[i]) / c[i] + 1, -1});
				} else{
					v.push_back({(a[i] - l) / (-c[i]) + 1, -1});
				}
			} if(a[i] > r) a[i] *= -1, c[i] *= -1;
			if(c[i] < 0) continue;
			ll s = (l - a[i] + c[i] - 1) / c[i];
			if(a[i] + c[i] * s <= r){
				v.push_back({s / c[i], 1});
				v.push_back({(r - a[i]) / c[i] + 1, -1});
			}
		}
	}
	int ans = 0, cnt = 0;
	sort(v.begin(), v.end());
	for(int i = 0; i < v.size();){
		int j = i;
		while(j < v.size() && v[j].first == v[i].first){
			cnt += v[j].second; j++;
		}
		ans = max(ans, cnt);
		i = j;
	}
	cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
    // #endif
    int t = 1;
    if(T) cin >> t;
    while(t--) test();
}

Compilation message

noras.cpp: In function 'void test()':
noras.cpp:67:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |  for(int i = 0; i < v.size();){
      |                 ~~^~~~~~~~~~
noras.cpp:69:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   while(j < v.size() && v[j].first == v[i].first){
      |         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6488 KB Output isn't correct
4 Halted 0 ms 0 KB -