Submission #403827

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4038272021-05-13 13:49:11donghwa722Abduction 2 (JOI17_abduction2)C++14
100 / 100
3531 ms265124 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<pair<int,int>,int> piii;
map<piii,ll> dp;
int A[50010],B[50010];
int a1[50010][17],a2[50010][17],b1[50010][17],b2[50010][17];
int h,w,q;
ll dfs(int a,int b,int d){
//printf("--%d %d %d\n",a,b,d);
if(dp.find({{a,b},d})!=dp.end()) return dp[{{a,b},d}];
int c=(d>=2?A[a]:B[b]); ll re=0;
// printf("%d\n",c);
if(d==0){
int x=a+1;
for(int i=16;i>=0;i--){
if(x>=h) break;
if(a1[x][i]<c) x+=(1<<i);
}
if(x>=h) re=h-1-a;
else re=max(dfs(x,b,2),dfs(x,b,3))+x-a;
}
else if(d==1){
int x=h-a;
for(int i=16;i>=0;i--){
if(x>=h) break;
if(a2[x][i]<c) x+=(1<<i);
}
if(x>=h) re=a;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

abduction2.cpp: In function 'int main()':
abduction2.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     scanf("%d %d %d",&h,&w,&q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
abduction2.cpp:58:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     for(int i=0;i<h;i++){scanf("%d",&A[i]); a1[i][0]=a2[h-1-i][0]=A[i];}
      |                          ~~~~~^~~~~~~~~~~~
abduction2.cpp:59:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     for(int i=0;i<w;i++){scanf("%d",&B[i]); b1[i][0]=b2[w-1-i][0]=B[i];}
      |                          ~~~~~^~~~~~~~~~~~
abduction2.cpp:71:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         int a,b; scanf("%d %d",&a,&b);
      |                  ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...