Submission #11051221


Source Code Expand

Copy
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int comb(int n, int m) {
  for (int i = 0; i < 20; ++i) {
    int u = (n >> i) & 1;
    int v = (m >> i) & 1;
    if (v > u) return 0;
  }
  return 1;
}

int solve(const vector<int>& a) {
  int n = a.size();
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (comb(n - 1, i)) ret = (ret + a[i]) % 2;
  }
  return ret;
}

const int N = 1e6 + 10;
char s[N];

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  bool found = false;
  scanf("%s", s);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
    if (a[i] % 2 == 0) found = true;
  }
  if (!found) {
    for (int i = 0; i < n; ++i) a[i] = (a[i] + 1) / 2;
    int ret = solve(a);
    printf("%d\n", ret * 2);
  } else {
    int ret = solve(a);
    printf("%d\n", ret);
  }
  return 0;
}

Submission Info

Submission Time
Task B - 123 Triangle
User cuiaoxiang
Language C++14 (GCC 5.4.1)
Score 700
Code Size 3250 Byte
Status AC
Exec Time 18 ms
Memory 5248 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:113:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
./Main.cpp:116:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", s);
                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 48
Set Name Test Cases
Sample 0_000.txt, 0_001.txt
All 0_000.txt, 0_001.txt, 1_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt, 1_040.txt, 1_041.txt, 1_042.txt, 1_043.txt, 1_044.txt, 1_045.txt, 1_046.txt, 1_047.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
1_002.txt AC 1 ms 256 KB
1_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 18 ms 5248 KB
1_009.txt AC 18 ms 5120 KB
1_010.txt AC 18 ms 5120 KB
1_011.txt AC 18 ms 5120 KB
1_012.txt AC 17 ms 5120 KB
1_013.txt AC 17 ms 5120 KB
1_014.txt AC 17 ms 5120 KB
1_015.txt AC 17 ms 5120 KB
1_016.txt AC 17 ms 2816 KB
1_017.txt AC 17 ms 2816 KB
1_018.txt AC 17 ms 2816 KB
1_019.txt AC 17 ms 2816 KB
1_020.txt AC 17 ms 2816 KB
1_021.txt AC 17 ms 2816 KB
1_022.txt AC 17 ms 2816 KB
1_023.txt AC 16 ms 2816 KB
1_024.txt AC 6 ms 2816 KB
1_025.txt AC 6 ms 2816 KB
1_026.txt AC 6 ms 2816 KB
1_027.txt AC 6 ms 2816 KB
1_028.txt AC 6 ms 2816 KB
1_029.txt AC 6 ms 2816 KB
1_030.txt AC 6 ms 2816 KB
1_031.txt AC 5 ms 2816 KB
1_032.txt AC 3 ms 1536 KB
1_033.txt AC 3 ms 1536 KB
1_034.txt AC 4 ms 1536 KB
1_035.txt AC 4 ms 1536 KB
1_036.txt AC 3 ms 1408 KB
1_037.txt AC 3 ms 1536 KB
1_038.txt AC 3 ms 1536 KB
1_039.txt AC 3 ms 1536 KB
1_040.txt AC 17 ms 5120 KB
1_041.txt AC 17 ms 5120 KB
1_042.txt AC 17 ms 2816 KB
1_043.txt AC 17 ms 2816 KB
1_044.txt AC 6 ms 2816 KB
1_045.txt AC 6 ms 2816 KB
1_046.txt AC 13 ms 5120 KB
1_047.txt AC 14 ms 5120 KB