Submission #68319977
Source Code Expand
/*
このコード、と~おれ!
Be accepted!
∧_∧
(。・ω・。)つ━☆・*。
⊂ ノ ・゜+.
しーJ °。+ *´¨)
.· ´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·'* ☆
*/
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
#include <array>
#include <chrono>
//#pragma GCC target("arch=skylake-avx512")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse4")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)
#define printLdb(a) printf("%.50Lf\n", a)
#define printdbd(a) printf("%.16lf\n", a)
#define prints(s) printf("%s\n", s.c_str())
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d))
using ll = long long;
using ull = unsigned long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-14;
const long double PI = acosl(-1.0L);
using namespace std;
void scans(string& str) {
char c;
str = "";
scanf("%c", &c);
if (c == '\n')scanf("%c", &c);
while (c != '\n' && c != -1 && c != ' ') {
str += c;
scanf("%c", &c);
}
}
void scanc(char& str) {
char c;
scanf("%c", &c);
if (c == -1)return;
while (c == '\n') {
scanf("%c", &c);
}
str = c;
}
double acot(double x) {
return PI / 2 - atan(x);
}
ll LSB(ll n) { return (n & (-n)); }
template<typename T>
inline T chmin(T& a, const T& b) {
if (a > b)a = b;
return a;
}
template<typename T>
inline T chmax(T& a, const T& b) {
if (a < b)a = b;
return a;
}
//cpp_int
#if __has_include(<boost/multiprecision/cpp_int.hpp>)
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace boost::multiprecision;
#else
using cpp_int = ll;
#endif
//atcoder library
#if __has_include(<atcoder/all>)
#include <atcoder/all>
//using namespace atcoder;
#endif
/*
random_device seed_gen;
mt19937 engine(seed_gen());
uniform_int_distribution dist(1, 100);
*/
/*----------------------------------------------------------------------------------*/
int main() {
int n;
scanf("%d", &n);
string s;
cin >> s;
vector dp(n + 1, vector(2, 0ll));
rep(i, n) {
if (s[i] == '1') {
dp[i + 1][0] += dp[i][0];
dp[i + 1][1] += dp[i][1] + 1;
}
else {
dp[i + 1][0] += dp[i][1] + 1;
dp[i + 1][1] += dp[i][0];
}
}
ll ans = 0;
rep(i, n + 1)ans += dp[i][1];
printf("%lld\n", ans);
Please AC;
}
Submission Info
| Submission Time |
|
| Task |
D - XNOR Operation |
| User |
null0124 |
| Language |
C++ 20 (gcc 12.2) |
| Score |
425 |
| Code Size |
3625 Byte |
| Status |
AC |
| Exec Time |
13 ms |
| Memory |
14696 KiB |
Compile Error
Main.cpp: In function ‘void scans(std::string&)’:
Main.cpp:76:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
76 | scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp:77:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
77 | if (c == '\n')scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp:80:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
80 | scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp: In function ‘void scanc(char&)’:
Main.cpp:86:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
86 | scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp:89:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
89 | scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:141:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
141 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
425 / 425 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 03_corner_00.txt, 03_corner_01.txt, 03_corner_02.txt, 03_corner_03.txt, 03_corner_04.txt, 03_corner_05.txt, 03_corner_06.txt, 03_corner_07.txt, 03_corner_08.txt, 03_corner_09.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
1 ms |
3892 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3864 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3888 KiB |
| 01_small_00.txt |
AC |
1 ms |
3732 KiB |
| 01_small_01.txt |
AC |
1 ms |
3752 KiB |
| 01_small_02.txt |
AC |
1 ms |
3892 KiB |
| 01_small_03.txt |
AC |
1 ms |
3864 KiB |
| 01_small_04.txt |
AC |
1 ms |
3768 KiB |
| 01_small_05.txt |
AC |
1 ms |
3880 KiB |
| 02_random_00.txt |
AC |
13 ms |
14212 KiB |
| 02_random_01.txt |
AC |
13 ms |
14592 KiB |
| 02_random_02.txt |
AC |
12 ms |
13608 KiB |
| 02_random_03.txt |
AC |
13 ms |
14416 KiB |
| 02_random_04.txt |
AC |
13 ms |
13820 KiB |
| 02_random_05.txt |
AC |
13 ms |
14696 KiB |
| 02_random_06.txt |
AC |
12 ms |
13640 KiB |
| 02_random_07.txt |
AC |
13 ms |
14612 KiB |
| 02_random_08.txt |
AC |
13 ms |
13920 KiB |
| 02_random_09.txt |
AC |
13 ms |
14672 KiB |
| 03_corner_00.txt |
AC |
13 ms |
14640 KiB |
| 03_corner_01.txt |
AC |
13 ms |
14600 KiB |
| 03_corner_02.txt |
AC |
13 ms |
14548 KiB |
| 03_corner_03.txt |
AC |
13 ms |
14600 KiB |
| 03_corner_04.txt |
AC |
13 ms |
14604 KiB |
| 03_corner_05.txt |
AC |
13 ms |
14600 KiB |
| 03_corner_06.txt |
AC |
13 ms |
14412 KiB |
| 03_corner_07.txt |
AC |
13 ms |
14600 KiB |
| 03_corner_08.txt |
AC |
13 ms |
14512 KiB |
| 03_corner_09.txt |
AC |
13 ms |
14672 KiB |