Submission #581563

# Submission time Handle Problem Language Result Execution time Memory
581563 2022-06-22T18:30:37 Z Omar_Elgedawy Miners (IOI07_miners) C++14
0 / 100
161 ms 208708 KB
#include <bits/stdc++.h>
using namespace std;
#define cin(vec)        for(auto& i : vec) cin >> i
#define cout(vec)       for(auto& i : vec) cout << i << " "; cout << "\n";
#define fast            ios::sync_with_stdio(0);cin.tie(0);
#define loop(i,a,b)     for (int i = a; i < b; i++)
#define F               first
#define S               second
#define pb(n)           push_back(n)
#define pf(n)           push_front(n)
#define dci(d)          fixed<<setprecision(d)
#define sp              ' '
#define el              '\n'
#define all(v)          v.begin(),v.end()
#define int             long long
int dx[8]= {0,0,1,-1,-1,1,1,-1};
int dy[8]= {-1,1,0,0,-1,1,-1,1};
int const N=1e5+1,M=1e3+1,Mod=1e9+7;
string s;
int n;
int dp[N][4][4][4][4];
int value(int a,int b,int c){
  set<int>s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  s.erase(0ll);
  return s.size();
}
int trans(char x){
  if(x=='Z')return 1;
  else x=='F'?2:3;
}
int rec(int idx, int left_a, int left_b, int right_a, int right_b){
  if(idx==n)return 0;
  int &ret=dp[idx][left_a][left_b][right_a][right_b];
  if(~ret)return ret;
  int c=trans(s[idx]);
  int c1=rec(idx+1,left_b,c,right_a,right_b)+value(left_a,left_b,c);
  int c2=rec(idx+1,left_a,left_b,right_b,c)+value(right_a,right_b,c);
  return ret=max(c1,c2);
}
void testcase(int h){
  cin>>n>>s;
  memset(dp,-1,sizeof dp);
  cout<<rec(0,0,0,0,0);
}
int32_t main()
{
  fast
  testcase(1);
  // int tc;cin>>tc;for(int i=1;i<=tc;i++)testcase(i);
  return 0;
}

Compilation message

miners.cpp: In function 'long long int trans(char)':
miners.cpp:32:18: warning: second operand of conditional expression has no effect [-Wunused-value]
   32 |   else x=='F'?2:3;
      |                  ^
miners.cpp:32:18: warning: third operand of conditional expression has no effect [-Wunused-value]
miners.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 200748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 200628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 200652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 200636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 200588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 200568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 200744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 201000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 201432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 202616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 133 ms 206632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 208708 KB Output isn't correct
2 Halted 0 ms 0 KB -