Submission #900551

# Submission time Handle Problem Language Result Execution time Memory
900551 2024-01-08T14:11:15 Z qin Cell Automaton (JOI23_cell) C++17
16 / 100
346 ms 48296 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ssize(x) int(x.size())
#define pn printf("\n");
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int inf = 2e09; ll infll = 2e18; int mod = 119<<23|1;
struct st{
		int t, type; ll c;
		bool operator<(const st &x) const{ return t == x.t ? type < x.type : t < x.t; }
};
void answer(){
		int n, q; scanf("%d%d", &n, &q);
		vector<int> t(n);
		for(int i = 0; i < n; ++i){
				int x, y; scanf("%d%d", &x, &y);
				t[i] = x;
		}
		sort(t.begin(), t.end());
		vector<st> ev;
		vector<int> qr(q);
		for(int i = 0; i < q; ++i){
				int T; scanf("%d", &T); qr[i] = T;
				ev.push_back({T, 2, 0});
		}
		for(int i = 0; i < n-1; ++i){
				ev.push_back({t[i+1]-t[i], 0, t[i+1]-t[i]+1});
				ev.push_back({t[i+1]-t[i]+1, 1, t[i+1]-t[i]+3});
		}
		sort(ev.begin(), ev.end());
		unordered_map<int, ll> result;
		ll offset = 0, cnt = n;
		for(st u : ev){
				//~ printf("%d %d %lld\n", u.t, u.type, u.c);
				if(u.type == 2) result[u.t] = (ll(u.t)*4*cnt)-offset;
				else offset += u.c;
				if(u.type == 1) --cnt, offset -= 4ll*u.t;
		} result[0] = n;
		for(int i = 0; i < q; ++i) printf("%lld\n", result[qr[i]]);
}
signed main(){
		int T = 1;
		for(++T; --T; ) answer();
		return 0;
}

Compilation message

cell.cpp: In function 'void answer()':
cell.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   int n, q; scanf("%d%d", &n, &q);
      |             ~~~~~^~~~~~~~~~~~~~~~
cell.cpp:18:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     int x, y; scanf("%d%d", &x, &y);
      |               ~~~~~^~~~~~~~~~~~~~~~
cell.cpp:25:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     int T; scanf("%d", &T); qr[i] = T;
      |            ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 7320 KB Output is correct
2 Correct 42 ms 8388 KB Output is correct
3 Correct 42 ms 8136 KB Output is correct
4 Correct 42 ms 7592 KB Output is correct
5 Correct 53 ms 8844 KB Output is correct
6 Correct 45 ms 7116 KB Output is correct
7 Correct 42 ms 8908 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 42 ms 7872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 7320 KB Output is correct
2 Correct 42 ms 8388 KB Output is correct
3 Correct 42 ms 8136 KB Output is correct
4 Correct 42 ms 7592 KB Output is correct
5 Correct 53 ms 8844 KB Output is correct
6 Correct 45 ms 7116 KB Output is correct
7 Correct 42 ms 8908 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 42 ms 7872 KB Output is correct
12 Correct 346 ms 48296 KB Output is correct
13 Correct 305 ms 47812 KB Output is correct
14 Correct 282 ms 47528 KB Output is correct
15 Correct 289 ms 47396 KB Output is correct
16 Correct 130 ms 38324 KB Output is correct
17 Correct 168 ms 38496 KB Output is correct
18 Correct 318 ms 41756 KB Output is correct
19 Correct 346 ms 47920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -