QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628808 | #7725. Just Sum Two Numbers | Afterlife | AC ✓ | 19ms | 5728kb | C++20 | 2.5kb | 2024-10-10 22:25:28 | 2024-10-10 22:25:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
struct P{
int x,y;
};
bool operator <(const P &a,const P &b)
{
return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
P operator -(const P &a,const P &b)
{
return {a.x-b.x,a.y-b.y};
}
int operator *(const P &a,const P &b)
{
return a.x*b.y-a.y*b.x;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
set<P> s;
for(int i=1;i<=n;i++)
{
string e;
cin>>e;
for(int j=1;j<=m;j++)
{
if(e[j-1]=='#')
{
s.insert({i,j});
// for(auto dx:{-1,0,1})
// for(auto dy:{-1,0,1})
// s.insert({i+dx,j+dy});
}
}
}
set<P> vis;
int S=0,c=0;
vector<pair<int,int> >dlt({{-1,0},{1,0},{0,-1},{0,1}});
for(auto [x,y]:s)
{
if(vis.count({x,y}))
continue;
queue<P> q;
q.push({x,y});
vis.insert({x,y});
vector<P> now;
while(!q.empty())
{
auto [x,y]=q.front();
q.pop();
now.push_back({x,y});
for(auto [i,j]:dlt)
{
if(s.find({x+i,y+j})==s.end())
continue;
if(vis.count({x+i,y+j}))
continue;
vis.insert({x+i,y+j});
q.push({x+i,y+j});
}
}
int B=now.size();
for(int i=0;i<B;i++)
{
auto [x,y]=now[i];
now.push_back({x+1,y});
now.push_back({x,y+1});
now.push_back({x+1,y+1});
}
sort(now.begin(),now.end());
vector<P> conv;
for(auto p:now)
{
while(conv.size()>1&&(p-conv.back())*(conv.back()-conv.end()[-2])>=0)
conv.pop_back();
conv.push_back(p);
}
reverse(now.begin(),now.end());
int m=conv.size();
for(auto p:now)
{
while(conv.size()>m&&(p-conv.back())*(conv.back()-conv.end()[-2])>=0)
conv.pop_back();
conv.push_back(p);
}
conv.pop_back();
m=conv.size();
int A=0;
for(int i=0;i<m;i++)
{
int j=(i+1)%m;
A+=conv[i]*conv[j];
}
A/=2;
if(1.*B/A>0.6)
S++;
else
c++;
}
S+=(c-1)*5;
cout<<S<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3832kb
input:
100 354 .......................................................................................................................................................................................................................................................................................................
output:
17
result:
ok 1 number(s): "17"
Test #2:
score: 0
Accepted
time: 4ms
memory: 4184kb
input:
135 269 ............................................................................................................................................................................................................................................................................. .........................
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 2ms
memory: 4204kb
input:
294 451 .......................................................................................................................................................................................................................................................................................................
output:
18
result:
ok 1 number(s): "18"
Test #4:
score: 0
Accepted
time: 8ms
memory: 4728kb
input:
234 701 .......................................................................................................................................................................................................................................................................................................
output:
32
result:
ok 1 number(s): "32"
Test #5:
score: 0
Accepted
time: 14ms
memory: 5488kb
input:
888 585 .......................................................................................................................................................................................................................................................................................................
output:
49
result:
ok 1 number(s): "49"
Test #6:
score: 0
Accepted
time: 3ms
memory: 4812kb
input:
579 350 .......................................................................................................................................................................................................................................................................................................
output:
26
result:
ok 1 number(s): "26"
Test #7:
score: 0
Accepted
time: 15ms
memory: 5144kb
input:
884 910 .......................................................................................................................................................................................................................................................................................................
output:
59
result:
ok 1 number(s): "59"
Test #8:
score: 0
Accepted
time: 10ms
memory: 5276kb
input:
652 717 .......................................................................................................................................................................................................................................................................................................
output:
51
result:
ok 1 number(s): "51"
Test #9:
score: 0
Accepted
time: 9ms
memory: 4728kb
input:
568 468 .......................................................................................................................................................................................................................................................................................................
output:
29
result:
ok 1 number(s): "29"
Test #10:
score: 0
Accepted
time: 19ms
memory: 5728kb
input:
923 959 .......................................................................................................................................................................................................................................................................................................
output:
61
result:
ok 1 number(s): "61"
Test #11:
score: 0
Accepted
time: 7ms
memory: 4336kb
input:
361 295 .......................................................................................................................................................................................................................................................................................................
output:
21
result:
ok 1 number(s): "21"
Test #12:
score: 0
Accepted
time: 13ms
memory: 5272kb
input:
712 929 .......................................................................................................................................................................................................................................................................................................
output:
50
result:
ok 1 number(s): "50"
Test #13:
score: 0
Accepted
time: 14ms
memory: 5452kb
input:
929 970 .......................................................................................................................................................................................................................................................................................................
output:
64
result:
ok 1 number(s): "64"
Test #14:
score: 0
Accepted
time: 5ms
memory: 4192kb
input:
394 346 .......................................................................................................................................................................................................................................................................................................
output:
24
result:
ok 1 number(s): "24"
Test #15:
score: 0
Accepted
time: 6ms
memory: 4796kb
input:
418 578 .......................................................................................................................................................................................................................................................................................................
output:
28
result:
ok 1 number(s): "28"
Test #16:
score: 0
Accepted
time: 8ms
memory: 4564kb
input:
457 499 .......................................................................................................................................................................................................................................................................................................
output:
27
result:
ok 1 number(s): "27"
Test #17:
score: 0
Accepted
time: 17ms
memory: 5428kb
input:
985 955 .......................................................................................................................................................................................................................................................................................................
output:
63
result:
ok 1 number(s): "63"
Test #18:
score: 0
Accepted
time: 7ms
memory: 4692kb
input:
209 704 .......................................................................................................................................................................................................................................................................................................
output:
30
result:
ok 1 number(s): "30"
Test #19:
score: 0
Accepted
time: 10ms
memory: 4736kb
input:
837 156 ............................................................................................................................................................ ..........................................................................................................................................
output:
37
result:
ok 1 number(s): "37"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
198 126 .............................................................................................................................. .............................................................................................................................. .........................................
output:
3
result:
ok 1 number(s): "3"
Test #21:
score: 0
Accepted
time: 13ms
memory: 5516kb
input:
996 684 .......................................................................................................................................................................................................................................................................................................
output:
57
result:
ok 1 number(s): "57"
Test #22:
score: 0
Accepted
time: 18ms
memory: 5540kb
input:
803 985 .......................................................................................................................................................................................................................................................................................................
output:
65
result:
ok 1 number(s): "65"
Test #23:
score: 0
Accepted
time: 14ms
memory: 5520kb
input:
948 820 .......................................................................................................................................................................................................................................................................................................
output:
62
result:
ok 1 number(s): "62"
Test #24:
score: 0
Accepted
time: 2ms
memory: 4112kb
input:
470 242 .................................................................................................................................................................................................................................................. ....................................................
output:
19
result:
ok 1 number(s): "19"
Test #25:
score: 0
Accepted
time: 14ms
memory: 5228kb
input:
967 248 ........................................................................................................................................................................................................................................................ ..............................................
output:
49
result:
ok 1 number(s): "49"
Test #26:
score: 0
Accepted
time: 2ms
memory: 4192kb
input:
323 198 ...................................................................................................................................................................................................... ................................................................................................
output:
17
result:
ok 1 number(s): "17"
Test #27:
score: 0
Accepted
time: 7ms
memory: 4776kb
input:
623 385 .......................................................................................................................................................................................................................................................................................................
output:
31
result:
ok 1 number(s): "31"
Test #28:
score: 0
Accepted
time: 16ms
memory: 5308kb
input:
955 959 .......................................................................................................................................................................................................................................................................................................
output:
65
result:
ok 1 number(s): "65"
Test #29:
score: 0
Accepted
time: 12ms
memory: 5528kb
input:
987 745 .......................................................................................................................................................................................................................................................................................................
output:
56
result:
ok 1 number(s): "56"
Test #30:
score: 0
Accepted
time: 5ms
memory: 4220kb
input:
328 309 .......................................................................................................................................................................................................................................................................................................
output:
14
result:
ok 1 number(s): "14"
Test #31:
score: 0
Accepted
time: 9ms
memory: 5292kb
input:
574 923 .......................................................................................................................................................................................................................................................................................................
output:
47
result:
ok 1 number(s): "47"
Test #32:
score: 0
Accepted
time: 4ms
memory: 4188kb
input:
180 259 ................................................................................................................................................................................................................................................................... ...................................
output:
13
result:
ok 1 number(s): "13"
Test #33:
score: 0
Accepted
time: 15ms
memory: 5228kb
input:
169 947 .......................................................................................................................................................................................................................................................................................................
output:
44
result:
ok 1 number(s): "44"
Test #34:
score: 0
Accepted
time: 8ms
memory: 4488kb
input:
892 244 .................................................................................................................................................................................................................................................... ..................................................
output:
36
result:
ok 1 number(s): "36"
Test #35:
score: 0
Accepted
time: 17ms
memory: 5452kb
input:
1000 598 ......................................................................................................................................................................................................................................................................................................
output:
57
result:
ok 1 number(s): "57"
Test #36:
score: 0
Accepted
time: 12ms
memory: 4992kb
input:
821 608 .......................................................................................................................................................................................................................................................................................................
output:
47
result:
ok 1 number(s): "47"
Test #37:
score: 0
Accepted
time: 14ms
memory: 5556kb
input:
223 988 .......................................................................................................................................................................................................................................................................................................
output:
51
result:
ok 1 number(s): "51"
Test #38:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
141 139 ........................................................................................................................................... ........................................................................................................................................... ...............
output:
2
result:
ok 1 number(s): "2"
Test #39:
score: 0
Accepted
time: 16ms
memory: 5296kb
input:
921 940 .......................................................................................................................................................................................................................................................................................................
output:
51
result:
ok 1 number(s): "51"
Test #40:
score: 0
Accepted
time: 4ms
memory: 4040kb
input:
317 124 ............................................................................................................................ ............................................................................................................................ .............................................
output:
14
result:
ok 1 number(s): "14"
Test #41:
score: 0
Accepted
time: 11ms
memory: 4884kb
input:
692 482 .......................................................................................................................................................................................................................................................................................................
output:
38
result:
ok 1 number(s): "38"
Test #42:
score: 0
Accepted
time: 5ms
memory: 4108kb
input:
464 313 .......................................................................................................................................................................................................................................................................................................
output:
25
result:
ok 1 number(s): "25"
Test #43:
score: 0
Accepted
time: 9ms
memory: 5288kb
input:
697 545 .......................................................................................................................................................................................................................................................................................................
output:
35
result:
ok 1 number(s): "35"
Test #44:
score: 0
Accepted
time: 7ms
memory: 4308kb
input:
265 445 .......................................................................................................................................................................................................................................................................................................
output:
19
result:
ok 1 number(s): "19"
Test #45:
score: 0
Accepted
time: 8ms
memory: 5212kb
input:
701 197 ..................................................................................................................................................................................................... .................................................................................................
output:
35
result:
ok 1 number(s): "35"
Test #46:
score: 0
Accepted
time: 14ms
memory: 5336kb
input:
572 761 .......................................................................................................................................................................................................................................................................................................
output:
41
result:
ok 1 number(s): "41"
Test #47:
score: 0
Accepted
time: 3ms
memory: 3880kb
input:
254 236 ............................................................................................................................................................................................................................................ ..........................................................
output:
9
result:
ok 1 number(s): "9"
Test #48:
score: 0
Accepted
time: 12ms
memory: 5044kb
input:
644 866 .......................................................................................................................................................................................................................................................................................................
output:
46
result:
ok 1 number(s): "46"
Test #49:
score: 0
Accepted
time: 12ms
memory: 5308kb
input:
528 898 .......................................................................................................................................................................................................................................................................................................
output:
44
result:
ok 1 number(s): "44"
Test #50:
score: 0
Accepted
time: 13ms
memory: 5008kb
input:
796 387 .......................................................................................................................................................................................................................................................................................................
output:
34
result:
ok 1 number(s): "34"
Test #51:
score: 0
Accepted
time: 14ms
memory: 5412kb
input:
862 785 .......................................................................................................................................................................................................................................................................................................
output:
51
result:
ok 1 number(s): "51"
Test #52:
score: 0
Accepted
time: 13ms
memory: 5128kb
input:
688 663 .......................................................................................................................................................................................................................................................................................................
output:
46
result:
ok 1 number(s): "46"
Test #53:
score: 0
Accepted
time: 8ms
memory: 4756kb
input:
372 589 .......................................................................................................................................................................................................................................................................................................
output:
25
result:
ok 1 number(s): "25"
Test #54:
score: 0
Accepted
time: 5ms
memory: 4232kb
input:
100 1000 ......................................................................................................................................................................................................................................................................................................
output:
94
result:
ok 1 number(s): "94"
Test #55:
score: 0
Accepted
time: 5ms
memory: 4184kb
input:
999 100 .................................................................................................... .................................................................................................... .............................................................................................
output:
94
result:
ok 1 number(s): "94"
Test #56:
score: 0
Accepted
time: 3ms
memory: 4552kb
input:
998 1000 ......................................................................................................................................................................................................................................................................................................
output:
134
result:
ok 1 number(s): "134"