답안 #791465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
791465 2023-07-24T06:48:12 Z 이종영(#10079) Bliskost (COI23_bliskost) C++17
100 / 100
145 ms 13128 KB
#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
//#include <bits/extc++.h>
//using namespace __gnu_pbds;
#define fi first
#define se second
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll=long long;
using ull=unsigned long long;
using db=long double;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using pdb=pair<db,db>;
using tii=tuple<int,int,int>;
using tdb=tuple<db,db,db>;
using tll=tuple<ll,ll,ll>;
using ti4=tuple<int,int,int,int>;
using tl4=tuple<ll,ll,ll,ll>;
using td4=tuple<db,db,db,db>;
//using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<> gen(1,100);
template <int MOD_> struct modnum{
private:
	int v;
public:
	static const int MOD = MOD_;
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
	friend bool operator < (const modnum& a, const modnum& b) { return a.v < b.v; }
	friend bool operator <= (const modnum& a, const modnum& b) { return a.v <= b.v; }
	friend bool operator > (const modnum& a, const modnum& b) { return a.v > b.v; }
	friend bool operator >= (const modnum& a, const modnum& b) { return a.v >= b.v; }
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	friend modnum pow(modnum a, ll p) {
		modnum ans = 1;
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	modnum operator ~ () const {
		modnum res;
		res.v = pow((modnum)v, MOD - 2).v;
		return res;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}
	modnum operator-() const { return modnum(-v); }
	modnum& operator++() { return *this += 1; }
	modnum operator++(int){ modnum tmp=*this; ++*this; return tmp; }
	modnum& operator--() { return *this -= 1; }
	modnum operator--(int){ modnum tmp=*this; --*this; return tmp; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
	friend ostream& operator<<(std::ostream& os, const modnum& o)
	{
		os << o.v;
		return os;
	}
	friend istream& operator>>(std::istream& is, modnum& o)
	{
		is >> o.v;
		return is;
	}
};
const ll mod=998244353,inf=1e18;
const int N=1e6+5,M=20;
using mi=modnum<mod>;
int n,q,a[N],b[N];
string s,t;
int S[2][2];
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>q>>s>>t;
	s=" "+s;
	t=" "+t;
	for(int i=1;i<=n;i++){
		a[i]=s[i]-'a';
		b[i]=t[i]-'a';
	}
	for(int i=0;i<=n;i++){
		S[0][i%2]=(S[0][i%2]+(a[i+1]-a[i])+52)%26;
		S[1][i%2]=(S[1][i%2]+(b[i+1]-b[i])+52)%26;
	}
	if(S[0][0]==S[1][0]&&S[0][1]==S[1][1]) cout<<"da\n";
	else cout<<"ne\n";
	for(int p,t=1;t<=q;t++){
		char c;
		cin>>p>>c;
		S[0][(p-1)%2]=(S[0][(p-1)%2]-(a[p]-a[p-1])+52)%26;
		S[0][p%2]=(S[0][p%2]-(a[p+1]-a[p])+52)%26;
		a[p]=c-'a';
		S[0][(p-1)%2]=(S[0][(p-1)%2]+(a[p]-a[p-1])+52)%26;
		S[0][p%2]=(S[0][p%2]+(a[p+1]-a[p])+52)%26;
		if(S[0][0]==S[1][0]&&S[0][1]==S[1][1]) cout<<"da\n";
		else cout<<"ne\n";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 10 ms 296 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 10 ms 296 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 11 ms 10092 KB Output is correct
32 Correct 11 ms 10104 KB Output is correct
33 Correct 13 ms 10112 KB Output is correct
34 Correct 11 ms 10148 KB Output is correct
35 Correct 10 ms 10128 KB Output is correct
36 Correct 10 ms 10060 KB Output is correct
37 Correct 11 ms 10060 KB Output is correct
38 Correct 11 ms 10036 KB Output is correct
39 Correct 11 ms 10008 KB Output is correct
40 Correct 12 ms 10052 KB Output is correct
41 Correct 12 ms 10112 KB Output is correct
42 Correct 13 ms 10052 KB Output is correct
43 Correct 11 ms 10064 KB Output is correct
44 Correct 11 ms 10120 KB Output is correct
45 Correct 10 ms 10088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 9 ms 596 KB Output is correct
17 Correct 10 ms 596 KB Output is correct
18 Correct 10 ms 596 KB Output is correct
19 Correct 10 ms 652 KB Output is correct
20 Correct 10 ms 596 KB Output is correct
21 Correct 10 ms 560 KB Output is correct
22 Correct 9 ms 596 KB Output is correct
23 Correct 9 ms 644 KB Output is correct
24 Correct 9 ms 596 KB Output is correct
25 Correct 9 ms 596 KB Output is correct
26 Correct 9 ms 596 KB Output is correct
27 Correct 9 ms 596 KB Output is correct
28 Correct 12 ms 640 KB Output is correct
29 Correct 11 ms 596 KB Output is correct
30 Correct 9 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 10 ms 296 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 9 ms 596 KB Output is correct
32 Correct 10 ms 596 KB Output is correct
33 Correct 10 ms 596 KB Output is correct
34 Correct 10 ms 652 KB Output is correct
35 Correct 10 ms 596 KB Output is correct
36 Correct 10 ms 560 KB Output is correct
37 Correct 9 ms 596 KB Output is correct
38 Correct 9 ms 644 KB Output is correct
39 Correct 9 ms 596 KB Output is correct
40 Correct 9 ms 596 KB Output is correct
41 Correct 9 ms 596 KB Output is correct
42 Correct 9 ms 596 KB Output is correct
43 Correct 12 ms 640 KB Output is correct
44 Correct 11 ms 596 KB Output is correct
45 Correct 9 ms 524 KB Output is correct
46 Correct 11 ms 596 KB Output is correct
47 Correct 14 ms 724 KB Output is correct
48 Correct 11 ms 596 KB Output is correct
49 Correct 11 ms 648 KB Output is correct
50 Correct 11 ms 612 KB Output is correct
51 Correct 10 ms 540 KB Output is correct
52 Correct 11 ms 596 KB Output is correct
53 Correct 11 ms 596 KB Output is correct
54 Correct 11 ms 548 KB Output is correct
55 Correct 11 ms 616 KB Output is correct
56 Correct 11 ms 660 KB Output is correct
57 Correct 11 ms 628 KB Output is correct
58 Correct 11 ms 596 KB Output is correct
59 Correct 10 ms 560 KB Output is correct
60 Correct 11 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 10 ms 296 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 11 ms 10092 KB Output is correct
32 Correct 11 ms 10104 KB Output is correct
33 Correct 13 ms 10112 KB Output is correct
34 Correct 11 ms 10148 KB Output is correct
35 Correct 10 ms 10128 KB Output is correct
36 Correct 10 ms 10060 KB Output is correct
37 Correct 11 ms 10060 KB Output is correct
38 Correct 11 ms 10036 KB Output is correct
39 Correct 11 ms 10008 KB Output is correct
40 Correct 12 ms 10052 KB Output is correct
41 Correct 12 ms 10112 KB Output is correct
42 Correct 13 ms 10052 KB Output is correct
43 Correct 11 ms 10064 KB Output is correct
44 Correct 11 ms 10120 KB Output is correct
45 Correct 10 ms 10088 KB Output is correct
46 Correct 9 ms 596 KB Output is correct
47 Correct 10 ms 596 KB Output is correct
48 Correct 10 ms 596 KB Output is correct
49 Correct 10 ms 652 KB Output is correct
50 Correct 10 ms 596 KB Output is correct
51 Correct 10 ms 560 KB Output is correct
52 Correct 9 ms 596 KB Output is correct
53 Correct 9 ms 644 KB Output is correct
54 Correct 9 ms 596 KB Output is correct
55 Correct 9 ms 596 KB Output is correct
56 Correct 9 ms 596 KB Output is correct
57 Correct 9 ms 596 KB Output is correct
58 Correct 12 ms 640 KB Output is correct
59 Correct 11 ms 596 KB Output is correct
60 Correct 9 ms 524 KB Output is correct
61 Correct 11 ms 596 KB Output is correct
62 Correct 14 ms 724 KB Output is correct
63 Correct 11 ms 596 KB Output is correct
64 Correct 11 ms 648 KB Output is correct
65 Correct 11 ms 612 KB Output is correct
66 Correct 10 ms 540 KB Output is correct
67 Correct 11 ms 596 KB Output is correct
68 Correct 11 ms 596 KB Output is correct
69 Correct 11 ms 548 KB Output is correct
70 Correct 11 ms 616 KB Output is correct
71 Correct 11 ms 660 KB Output is correct
72 Correct 11 ms 628 KB Output is correct
73 Correct 11 ms 596 KB Output is correct
74 Correct 10 ms 560 KB Output is correct
75 Correct 11 ms 604 KB Output is correct
76 Correct 145 ms 13100 KB Output is correct
77 Correct 140 ms 13116 KB Output is correct
78 Correct 128 ms 13040 KB Output is correct
79 Correct 136 ms 13084 KB Output is correct
80 Correct 133 ms 13016 KB Output is correct
81 Correct 128 ms 13100 KB Output is correct
82 Correct 134 ms 13016 KB Output is correct
83 Correct 129 ms 13040 KB Output is correct
84 Correct 128 ms 13008 KB Output is correct
85 Correct 123 ms 13104 KB Output is correct
86 Correct 132 ms 13128 KB Output is correct
87 Correct 135 ms 13096 KB Output is correct
88 Correct 128 ms 13012 KB Output is correct
89 Correct 124 ms 13124 KB Output is correct
90 Correct 142 ms 13000 KB Output is correct