QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244082#7022. Best ACMer Solves the Hardest ProblemyiyiyiAC ✓1618ms855756kbC++203.9kb2023-11-08 20:58:522023-11-08 20:58:52

Judging History

你现在查看的是最新测评结果

  • [2023-11-08 20:58:52]
  • 评测
  • 测评结果:AC
  • 用时:1618ms
  • 内存:855756kb
  • [2023-11-08 20:58:52]
  • 提交

answer

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<bitset>
#include<set> 
#define int long long
#define ll long long
#define lowbit(x) x&(-x)
#define mp make_pair
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define forE(i,x) for(int i=head[x];i;i=nxt[i])
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int maxn=2e5+5;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+(c-'0');
		c=getchar();
	}
	return x*f;
}
int T;
vector<pii> pw[20000005];
int p[6050][6050];
vector<pii> st;
set<pii> s;
bool check(int x,int y)
{
    return x>0&&y>0&&x<=6000&&y<=6000;
}
signed main()
{
    for(ll i=1;i*i<=10000000;i++)
    {
        ll x=i*i;
        pw[x].push_back({i,0});
        for(ll j=1;j<=i&&j*j+i*i<=10000000;j++) pw[i*i+j*j].push_back({i,j});
    }
    pw[0].push_back({0,0});
	T=read();
    rep(P,1,T)
    {
        printf("Case #%lld:\n",P);
        int n=read(),m=read();
        rep(i,1,n)
        {
            int x=read(),y=read(),w=read();
            p[x][y]+=w;
            st.push_back({x,y});
        }
        int lastans=0;
        rep(i,1,m)
        {
            int opt=read();
            int x=(read()+lastans)%6000+1,y=(read()+lastans)%6000+1;
            // printf("%lld %lld\n",x,y);
            if(opt==1)
            {
                int w=read();
                p[x][y]=w;
                st.push_back({x,y});
            }
            else if(opt==2) p[x][y]=0;
            else if(opt==3)
            {
                int k=read(),w=read();
                for(pii u:pw[k])
                {
                    int px=u.first,py=u.second;
                    if(check(x+px,y+py)&&p[x+px][y+py]) s.insert({x+px,y+py}); 
                    if(check(x+px,y-py)&&p[x+px][y-py]) s.insert({x+px,y-py}); 
                    if(check(x-px,y+py)&&p[x-px][y+py]) s.insert({x-px,y+py}); 
                    if(check(x-px,y-py)&&p[x-px][y-py]) s.insert({x-px,y-py});  
                    if(px==py) continue;
                    swap(px,py);
                    if(check(x+px,y+py)&&p[x+px][y+py]) s.insert({x+px,y+py}); 
                    if(check(x+px,y-py)&&p[x+px][y-py]) s.insert({x+px,y-py});  
                    if(check(x-px,y+py)&&p[x-px][y+py]) s.insert({x-px,y+py}); 
                    if(check(x-px,y-py)&&p[x-px][y-py]) s.insert({x-px,y-py}); 
                }
                for(auto u:s) p[u.first][u.second]+=w;
                s.clear();
            }
            else
            {
                int ans=0;
                int k=read();
                for(pii u:pw[k])
                {
                    int px=u.first,py=u.second;
                    if(check(x+px,y+py)&&p[x+px][y+py]) s.insert({x+px,y+py}); 
                    if(check(x+px,y-py)&&p[x+px][y-py]) s.insert({x+px,y-py}); 
                    if(check(x-px,y+py)&&p[x-px][y+py]) s.insert({x-px,y+py}); 
                    if(check(x-px,y-py)&&p[x-px][y-py]) s.insert({x-px,y-py});  
                    if(px==py) continue;
                    swap(px,py);
                    if(check(x+px,y+py)&&p[x+px][y+py]) s.insert({x+px,y+py}); 
                    if(check(x+px,y-py)&&p[x+px][y-py]) s.insert({x+px,y-py});  
                    if(check(x-px,y+py)&&p[x-px][y+py]) s.insert({x-px,y+py}); 
                    if(check(x-px,y-py)&&p[x-px][y-py]) s.insert({x-px,y-py}); 
                }
                for(pii u:s) ans+=p[u.first][u.second];
                printf("%lld\n",lastans=ans);
                s.clear();
            }
        }
        for(auto x:st) p[x.first][x.second]=0;
        st.clear(); 
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 433ms
memory: 571896kb

input:

1
3 6
2999 3000 1
3001 3000 1
3000 2999 1
1 2999 3000 1
4 2999 2999 1
2 2995 2996
3 2995 2995 1 1
4 2995 2995 1
4 3000 3000 1

output:

Case #1:
4
6
0

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1618ms
memory: 855756kb

input:

1000
10 10
3505 4093 1071
2828 5767 1951
4087 1947 2419
1348 1177 6000
271 3657 1998
4584 132 495
4260 4693 129
5112 3484 1918
5754 3661 3066
1629 1302 1691
1 5838 2560 2113
2 4086 1946
2 4583 131
4 4970 4439 4284065
3 2945 677 1239925 5721
4 1523 2487 2014037
2 876 3815
3 5116 5955 680746 5170
3 79...

output:

Case #1:
2113
1951
Case #2:
33271
30497
30497
Case #3:
29279
47107
Case #4:
852
3353
7244
5176
Case #5:
11088
Case #6:
122515
185005
Case #7:
31427
78290
Case #8:
4549
2091
12806
Case #9:
188803
Case #10:
83837
Case #11:
58111
58111
140591
Case #12:
5457
4290
Case #13:
22748
148509
Case #14:
1674
60...

result:

ok 405746 lines