Submission #1107735

# Submission time Handle Problem Language Result Execution time Memory
1107735 2024-11-02T04:14:15 Z 8pete8 Stray Cat (JOI20_stray) C++17
91 / 100
45 ms 16412 KB
#include "Anthony.h"
#include <vector>
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
using namespace std;
namespace {

int FunctionExample(int i, int A) {
  return i % A;
}

}  // namespace

vector<int> Mark(int n,int m, int a, int b,vector<int> U,vector<int> V) {
  vector<int> X(m);
  vector<int>lvl(n+1,1e9),vis(n,0);
  vector<vector<pii>>adj(n);
  for(int i=0;i<m;i++){
    adj[U[i]].pb({V[i],i}),adj[V[i]].pb({U[i],i});
  }
  queue<int>q;
  lvl[0]=0;
  q.push(0);
  while(!q.empty()){
    int cur=q.front();
    q.pop();
    if(vis[cur])continue;
    vis[cur]=1;
    for(auto i:adj[cur])if(!vis[i.f]&&lvl[i.f]>lvl[cur]+1){
      lvl[i.f]=lvl[cur]+1;
      q.push(i.f);
    }
  }
  if(a>=3){
    for(int i=0;i<n;i++)for(auto j:adj[i]){
      if(lvl[j.f]<lvl[i])X[j.s]=(lvl[j.f]%3);
      else X[j.s]=lvl[i]%3;
    }
  }
  else{
    //0 0 1 1 0 1
    //1 1 0 1 0 0
    vector<int>pat={0,0,1,1,0,1};
    vector<int>val(n,0);
    function<void(int,int,int)> dfs=[&](int cur,int p,int c){
      for(auto i:adj[cur])if(i.f!=p){
        if(val[cur]>1)assert(0);
        if(adj[cur].size()>2){
          c=0;
          val[i.f]=(val[cur]^1);
          X[i.s]=val[i.f];
          dfs(i.f,cur,c);
        }
        else{
          if(c==0){
            val[i.f]=(val[cur]^1);
            if(val[i.f])c=2;
            if(cur)c++;
            X[i.s]=val[i.f];
            if(val[i.f]!=pat[c%6]){
              cout<<val[i.f]<<" "<<pat[c%6]<<"WHAT\n";
              exit(0);
            }
            dfs(i.f,cur,c+1);
          }
          else{
            val[i.f]=pat[c%6];
            X[i.s]=val[i.f];
            dfs(i.f,cur,c+1);
          }
        }
        
      }
    };
    dfs(0,-1,0);
    //for(auto i:adj[149])cout<<i.f<<" "<<X[i.s]<<"HUH\n";
  }
  //for(int i=0;i<m;i++)cout<<U[i]<<" "<<V[i]<<" "<<X[i]<<'\n';
  return X;
}
#include "Catherine.h"
#include <vector>
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
using namespace std;
using namespace std;
namespace {

int a, b;
int variable_example = 0;
int found=0;
int add[40000];
deque<int>cor={1,0,1,1,0,0};
vector<int>have;
int st=0,last=0;
}
void Init(int A, int B){
  ::a = A;
  ::b = B;
  found=0;
  have.clear();
}
int Move(vector<int> y){
  int cnt=0;
  for(auto i:y)cnt+=!!i;
  if(a>=3){
    if(cnt==0)assert(0);
    if(cnt==1){
      for(int i=0;i<y.size();i++)if(y[i])return i;
    }
    if(cnt==2){
      if(y[0]&&y[2])return 2;
      if(y[1]&&y[2])return 1;
      if(y[0]&&y[1])return 0;
    }
    assert(0);
  }
  else{
    int one=0,two=0;
    if(st==0){
      for(int i=0;i<y.size();i++)if(y[i]==1)one++;
      if(one==1){
        st=1;
        found=1;
        for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;
      }
      else{
        st=1;
        for(int i=0;i<y.size();i++)if(y[i]){
          have.pb(i);
          return last=i; 
        }
      }
      st=1;
    }
    if(!found){
      if(cnt==0){
        found=1;
        return -1;
      }
      y[last]++;
      for(int i=0;i<y.size();i++)two+=y[i];
      if(two>2){
        //cout<<"THISS??\n";
        found=1;
        for(int i=0;i<y.size();i++)if(y[i]==1){
          if(i!=last)return last=i;
          return -1;
        }
      }
      y[last]--;
      if(have.size()<6){
        for(int i=0;i<y.size();i++)if(y[i]){
          have.pb(i);
          return last=i;
        }
      }
      else{
        int same=0;
        for(int i=0;i<6;i++){
          int yes=1;
          for(int j=0;j<6;j++)if(have[j]!=cor[j])yes=0;
          same|=yes;
          cor.push_back(cor.front());
          cor.pop_front();
        }
        found=1;
        if(!same)return -1;
      }
    }
    if(found){
      for(int i=0;i<y.size();i++)if(y[i]==1)one++;
      //for(int i=0;i<y.size();i++)cout<<y[i]<<" ";
      //cout<<'\n';
      if(one==1){
        for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;

      }
      else{
        y[last]++;
        //cout<<"HERE\n";
        for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;
      }
    }
  }
  assert(0);
  return -1;
}


Compilation message

Anthony.cpp:34:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   34 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
Anthony.cpp:38:33: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   38 | int FunctionExample(int i, int A) {
      |                                 ^
Anthony.cpp:44:71: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   44 | vector<int> Mark(int n,int m, int a, int b,vector<int> U,vector<int> V) {
      |                                                                       ^
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:75:60: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   75 |     function<void(int,int,int)> dfs=[&](int cur,int p,int c){
      |                                                            ^
Anthony.cpp: At global scope:
Anthony.cpp:38:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
   38 | int FunctionExample(int i, int A) {
      |     ^~~~~~~~~~~~~~~

Catherine.cpp:34:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   34 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
Catherine.cpp:47:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   47 | void Init(int A, int B){
      |                       ^
Catherine.cpp:53:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   53 | int Move(vector<int> y){
      |                       ^
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |       for(int i=0;i<y.size();i++)if(y[i])return i;
      |                   ~^~~~~~~~~
Catherine.cpp:71:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |       for(int i=0;i<y.size();i++)if(y[i]==1)one++;
      |                   ~^~~~~~~~~
Catherine.cpp:75:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;
      |                     ~^~~~~~~~~
Catherine.cpp:79:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for(int i=0;i<y.size();i++)if(y[i]){
      |                     ~^~~~~~~~~
Catherine.cpp:92:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |       for(int i=0;i<y.size();i++)two+=y[i];
      |                   ~^~~~~~~~~
Catherine.cpp:96:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |         for(int i=0;i<y.size();i++)if(y[i]==1){
      |                     ~^~~~~~~~~
Catherine.cpp:103:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |         for(int i=0;i<y.size();i++)if(y[i]){
      |                     ~^~~~~~~~~
Catherine.cpp:122:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |       for(int i=0;i<y.size();i++)if(y[i]==1)one++;
      |                   ~^~~~~~~~~
Catherine.cpp:126:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |         for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;
      |                     ~^~~~~~~~~
Catherine.cpp:132:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  132 |         for(int i=0;i<y.size();i++)if(y[i]==1)return last=i;
      |                     ~^~~~~~~~~
Catherine.cpp: At global scope:
Catherine.cpp:42:5: warning: '{anonymous}::add' defined but not used [-Wunused-variable]
   42 | int add[40000];
      |     ^~~
Catherine.cpp:40:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   40 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15456 KB Output is correct
2 Correct 1 ms 764 KB Output is correct
3 Correct 26 ms 14684 KB Output is correct
4 Correct 36 ms 16412 KB Output is correct
5 Correct 34 ms 16272 KB Output is correct
6 Correct 32 ms 15076 KB Output is correct
7 Correct 31 ms 15196 KB Output is correct
8 Correct 34 ms 15932 KB Output is correct
9 Correct 39 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15456 KB Output is correct
2 Correct 1 ms 764 KB Output is correct
3 Correct 26 ms 14684 KB Output is correct
4 Correct 36 ms 16412 KB Output is correct
5 Correct 34 ms 16272 KB Output is correct
6 Correct 32 ms 15076 KB Output is correct
7 Correct 31 ms 15196 KB Output is correct
8 Correct 34 ms 15932 KB Output is correct
9 Correct 39 ms 15964 KB Output is correct
10 Correct 26 ms 13268 KB Output is correct
11 Correct 27 ms 13104 KB Output is correct
12 Correct 30 ms 13240 KB Output is correct
13 Correct 27 ms 13228 KB Output is correct
14 Correct 32 ms 13472 KB Output is correct
15 Correct 45 ms 13868 KB Output is correct
16 Correct 35 ms 15760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 13024 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 26 ms 12380 KB Output is correct
4 Correct 38 ms 14212 KB Output is correct
5 Correct 40 ms 14168 KB Output is correct
6 Correct 32 ms 12892 KB Output is correct
7 Correct 30 ms 12900 KB Output is correct
8 Correct 33 ms 13660 KB Output is correct
9 Correct 34 ms 13664 KB Output is correct
10 Correct 32 ms 13412 KB Output is correct
11 Correct 30 ms 13664 KB Output is correct
12 Correct 34 ms 13404 KB Output is correct
13 Correct 39 ms 13412 KB Output is correct
14 Correct 33 ms 13672 KB Output is correct
15 Correct 37 ms 13584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 13024 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 26 ms 12380 KB Output is correct
4 Correct 38 ms 14212 KB Output is correct
5 Correct 40 ms 14168 KB Output is correct
6 Correct 32 ms 12892 KB Output is correct
7 Correct 30 ms 12900 KB Output is correct
8 Correct 33 ms 13660 KB Output is correct
9 Correct 34 ms 13664 KB Output is correct
10 Correct 32 ms 13412 KB Output is correct
11 Correct 30 ms 13664 KB Output is correct
12 Correct 34 ms 13404 KB Output is correct
13 Correct 39 ms 13412 KB Output is correct
14 Correct 33 ms 13672 KB Output is correct
15 Correct 37 ms 13584 KB Output is correct
16 Correct 26 ms 11360 KB Output is correct
17 Correct 28 ms 11224 KB Output is correct
18 Correct 27 ms 11220 KB Output is correct
19 Correct 26 ms 11220 KB Output is correct
20 Correct 38 ms 11736 KB Output is correct
21 Correct 28 ms 11724 KB Output is correct
22 Correct 33 ms 13884 KB Output is correct
23 Correct 30 ms 11480 KB Output is correct
24 Correct 28 ms 11468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 1 ms 772 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1204 KB Output is correct
5 Correct 2 ms 1036 KB Output is correct
6 Correct 2 ms 1036 KB Output is correct
7 Correct 2 ms 1036 KB Output is correct
8 Correct 2 ms 1032 KB Output is correct
9 Correct 2 ms 1028 KB Output is correct
10 Correct 2 ms 1040 KB Output is correct
11 Correct 2 ms 1028 KB Output is correct
12 Correct 2 ms 1028 KB Output is correct
13 Correct 2 ms 1040 KB Output is correct
14 Correct 2 ms 1144 KB Output is correct
15 Correct 2 ms 1028 KB Output is correct
16 Correct 2 ms 1016 KB Output is correct
17 Correct 2 ms 1040 KB Output is correct
18 Correct 2 ms 1040 KB Output is correct
19 Correct 2 ms 1028 KB Output is correct
20 Correct 2 ms 1040 KB Output is correct
21 Correct 2 ms 1044 KB Output is correct
22 Correct 2 ms 1040 KB Output is correct
23 Correct 2 ms 1028 KB Output is correct
24 Correct 2 ms 1040 KB Output is correct
25 Correct 2 ms 1040 KB Output is correct
26 Correct 2 ms 1028 KB Output is correct
27 Correct 2 ms 1028 KB Output is correct
28 Correct 3 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 11100 KB Output is correct
2 Correct 30 ms 13068 KB Output is correct
3 Correct 1 ms 932 KB Output is correct
4 Correct 22 ms 11100 KB Output is correct
5 Correct 34 ms 15172 KB Output is correct
6 Correct 36 ms 15188 KB Output is correct
7 Correct 30 ms 14176 KB Output is correct
8 Correct 32 ms 14112 KB Output is correct
9 Correct 36 ms 15456 KB Output is correct
10 Correct 34 ms 15460 KB Output is correct
11 Correct 34 ms 15460 KB Output is correct
12 Correct 34 ms 15424 KB Output is correct
13 Correct 34 ms 15428 KB Output is correct
14 Correct 34 ms 15968 KB Output is correct
15 Correct 35 ms 15456 KB Output is correct
16 Correct 39 ms 15300 KB Output is correct
17 Correct 38 ms 15204 KB Output is correct
18 Correct 37 ms 15124 KB Output is correct
19 Correct 38 ms 15104 KB Output is correct
20 Correct 36 ms 15176 KB Output is correct
21 Correct 38 ms 15200 KB Output is correct
22 Correct 37 ms 15200 KB Output is correct
23 Correct 31 ms 11660 KB Output is correct
24 Correct 28 ms 11616 KB Output is correct
25 Correct 29 ms 12456 KB Output is correct
26 Correct 30 ms 12332 KB Output is correct
27 Correct 36 ms 13668 KB Output is correct
28 Correct 36 ms 13648 KB Output is correct
29 Correct 32 ms 13888 KB Output is correct
30 Correct 33 ms 13880 KB Output is correct
31 Correct 30 ms 11576 KB Output is correct
32 Correct 28 ms 11708 KB Output is correct
33 Correct 30 ms 12396 KB Output is correct
34 Correct 27 ms 12332 KB Output is correct
35 Correct 30 ms 13276 KB Output is correct
36 Correct 32 ms 13372 KB Output is correct
37 Correct 32 ms 13420 KB Output is correct
38 Correct 30 ms 13368 KB Output is correct
39 Correct 30 ms 13392 KB Output is correct
40 Correct 30 ms 13272 KB Output is correct
41 Correct 34 ms 14308 KB Output is correct
42 Correct 35 ms 14176 KB Output is correct
43 Correct 38 ms 14176 KB Output is correct
44 Correct 40 ms 14432 KB Output is correct
45 Correct 36 ms 14440 KB Output is correct
46 Correct 39 ms 14400 KB Output is correct
47 Correct 31 ms 13152 KB Output is correct
48 Correct 38 ms 13080 KB Output is correct
49 Correct 28 ms 13116 KB Output is correct
50 Correct 31 ms 13108 KB Output is correct
51 Correct 27 ms 11840 KB Output is correct
52 Correct 27 ms 11728 KB Output is correct
53 Correct 27 ms 11844 KB Output is correct
54 Correct 27 ms 11852 KB Output is correct
55 Correct 27 ms 11824 KB Output is correct
56 Correct 27 ms 11788 KB Output is correct
57 Correct 27 ms 12028 KB Output is correct
58 Correct 27 ms 12160 KB Output is correct
59 Correct 34 ms 11832 KB Output is correct
60 Correct 30 ms 11804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 11152 KB Output is correct
2 Correct 28 ms 13136 KB Output is correct
3 Correct 1 ms 764 KB Output is correct
4 Correct 22 ms 11108 KB Output is correct
5 Correct 36 ms 15200 KB Output is correct
6 Correct 34 ms 15204 KB Output is correct
7 Incorrect 27 ms 14180 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -