QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#390065 | #5102. Dungeon Crawler | 0_GB_RAM# | WA | 1ms | 3620kb | C++23 | 2.4kb | 2024-04-15 01:45:13 | 2024-04-15 01:45:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//#define int ll
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) begin(x),end(x)
#define sz(x) (int)((x).size())
using pii=pair<int,int>;
using vi=vector<int>;
#define fi first
#define se second
#define pb push_back
int t[200500];
int get(int v)
{
v++;
int s = 0;
for (int i=v; i>0; i=i&(i+1), i--)
s += t[i];
return s;
}
void upd(int v, int x)
{
v++;
for (int i=v; i<200500; i|=(i+1))
t[i] += x;
}
int n, m, s;
int gett(int v)
{
return get((v+n+n+n)%n);
}
void upd(int l, int r, int d)
{
if (l > r)
return;
for (int i=-1; i<=1; i++)
{
int lx = max(l+i*n, 0);
int rx = min(r+i*n, n-1);
if (lx <= rx)
upd(lx, d), upd(rx+1, -d);
}
}
void bridge(int t) {
// for (int i=0; i<n; i++)
// cout<<get(i)<<" ";
// cout<<"\n";
int x = get(t);
int y = get((t + 1) % n);
int d = y - x;
upd(t, d);
upd(t + 1, -d);
upd((t + 1) % n, -d);
upd((t + 1) % n + 1, d);
swap(x, y);
if (x < y)
{
if (gett(t+2) < y - 1)
upd((t+1)%n, -1), upd((t+1)%n+1, 1);
int r = t;
int l = t-n;
while (r-l>1)
{
int m = (l+r)/2;
if (gett(m) - x == t - m + 1)
r = m;
else
l = m;
}
upd(r, t-1, -1);
}
else
{
if (gett(t-1) < x - 1)
upd(t, -1), upd(t+1, 1);
int l = t+1;
int r = t+n+1;
while (r-l>1)
{
int m = (l+r)/2;
if (gett(m) - y == m - (t+1) + 1)
l = m;
else
r = m;
}
upd(t+2, l, -1);
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin>>n>>m>>s;
s--;
vector<pair<int, int> > br;
for (int i=0; i<m; i++)
{
int d, t;
cin>>d>>t;
t--;
br.pb({d, t});
}
for (int i=0; i<n; i++)
{
int d = min(abs(i-s), n-abs(i-s));
upd(i, d);
upd(i+1, -d);
}
sort(br.begin(), br.end());
reverse(br.begin(), br.end());
for (auto [d, t] : br)
bridge(t);
for (int i=0; i<n; i++)
cout<<get(i)<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3620kb
input:
22 5 1 2 7 2 3 5 3 4 8 3 6 6 3 7 3 2 5 6 5 8 2 8 9 11 2 10 16 1 11 12 11 12 4 11 13 9 1 14 25 14 15 4 15 16 5 15 17 6 15 18 1 15 19 8 14 20 7 20 21 9 20 22 17 1 19 9 1 9 19 1 8 9 1 9 8 2 22 11
output:
0 1 2 2 3 4 5 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1
result:
wrong answer 1st lines differ - expected: '316', found: '0'