Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<bits/stdc++.h>
- #include<iostream>
- #include<fstream>
- #include<vector>
- #define long long long
- #define nln '\n'
- const long N = 1e2+10;
- using namespace std;
- // Global variables: f1, f2, n, k, mat, squ
- fstream f1, f2;
- inline void openf()
- {
- f1.open("xoanoc.inp", ios:: in);
- f2.open("xoanoc.out", ios:: out);
- }
- inline void closef()
- {
- f1.close();
- f2.close();
- }
- long n, k, squ = 0;
- vector<vector<long>> mat(N), cam(N);
- void data()
- {
- f1.tie(0)->sync_with_stdio(0);
- f2.tie(0)->sync_with_stdio(0);
- cin >> n >> k;
- for (long i = 1; i-1 != n; ++i)
- {
- cam[i].resize(n+1, 0);
- mat[i].push_back(0);
- for (long j = 1; j-1 != n; ++j)
- {
- bool x;
- cin >> x;
- if (!x)
- ++squ;
- mat[i].push_back(x);
- }
- }
- }
- long lo1, lo2;
- void process()
- {
- bool neg = 0;
- squ--;
- if ((k/squ) % 2 == 1)
- neg = 1;
- long step = k % squ;
- if (neg)
- step = squ - step;
- // Turn on
- long i = 1, j = 1, met = 0;
- while (step >= 0)
- {
- lo1 = i; lo2 = j;
- cam[i][j] = 1;
- if (!mat[i][j])
- {
- mat[i][j] = 1;
- --step;
- }
- if (met == 4)
- met = 0;
- if (met == 0)
- {
- ++j;
- if (j == n+1 || cam[i][j])
- {
- --j;
- ++i;
- ++met;
- }
- continue;
- }
- if (met == 1)
- {
- ++i;
- if (i == n+1 || cam[i][j])
- {
- --i;
- --j;
- ++met;
- }
- continue;
- }
- if (met == 2)
- {
- --j;
- if (j == 0 || cam[i][j])
- {
- ++j;
- --i;
- ++met;
- }
- continue;
- }
- if (met == 3)
- {
- --i;
- if (i == 0 || cam[i][j])
- {
- ++i;
- ++j;
- ++met;
- }
- }
- }
- }
- void view()
- {
- cout<< lo1 << ' ' << lo2 << nln;
- }
- int main()
- {
- openf();
- data();
- process();
- view();
- closef();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment