Submission #888480

# Submission time Handle Problem Language Result Execution time Memory
888480 2023-12-17T14:13:00 Z fanwen Bliskost (COI23_bliskost) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define ll long long
#define file(name)                  \
    if(fopen(name".inp", "r"))      \
        freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout); 

const int MAX = 1e5 + 5;

int n, a[MAX], b[MAX], q, c[MAX];

bool check() {
	if(1LL * n * q > 1e8) return false;
	for (int i = 1; i < n; ++i) {
		c[i] = a[i];
	}

	for (int i = 1; i < n; ++i) {
		int d = (b[i] - c[i] + 26) % 26;
		c[i + 1] += d;
		c[i + 1] %= 26;
	}
	return c[n] == b[n];
}

void you_make_it(void) {
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
    	char x; cin >> x; a[i] = x - 'a';
    }
    for (int i = 1; i <= n; ++i) {
    	char x; cin >> x; b[i] = x - 'a';
    }

    cout << (check() ? "da" : "ne") << '\n';
    while(q--) {
    	int p; char x; cin >> p >> x;
    	a[p] = x - 'a';
	    cout << (check() ? "da" : "ne") << '\n';

    }
}

signed main() {

#ifdef LOCAL
    freopen("TASK.inp", "r", stdin);
    freopen("TASK.out", "w", stdout);
#endif
    file("bliskost");
    auto start_time = chrono::steady_clock::now();

    cin.tie(0), cout.tie(0) -> sync_with_stdio(0);

    you_make_it();

    auto end_time = chrono::steady_clock::now();

    cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;

    return (0 ^ 0);
}

// Dream it. Wish it. Do it.

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:54:5: note: in expansion of macro 'file'
   54 |     file("bliskost");
      |     ^~~~
Main.cpp:10:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:54:5: note: in expansion of macro 'file'
   54 |     file("bliskost");
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -