Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<bits/stdc++.h>
- #include<fstream>
- #include<vector>
- #include<iostream>
- #define long long long
- #define nln '\n'
- using namespace std;
- // Global variables: f1, f2, n, m
- fstream f1, f2;
- inline void openf()
- {
- f1.open("daycon.inp", ios:: in);
- f2.open("daycon.out", ios:: out);
- }
- inline void closef()
- {
- f1.close();
- f2.close();
- }
- long n, m;
- vector<long> a;
- void data()
- {
- f1.tie(0)->sync_with_stdio(0);
- f2.tie(0)->sync_with_stdio(0);
- f1 >> n >> m;
- }
- bool check(long loc)
- {
- long dis = loc / 2;
- for (long i = 1; i <= dis; ++i)
- {
- bool sam = 1;
- for (long j = loc - i*2 + 1; j <= loc-i; ++j)
- if (a[j] != a[j+i])
- {
- sam = 0;
- break;
- }
- if (sam)
- return 0;
- }
- return 1;
- }
- long cou = 0;
- void recursion(long i)
- {
- if (i > n)
- {
- ++cou;
- f2 << cou << " : ";
- for (long j = 1; j <= n; ++j)
- f2 << a[j];
- f2 << nln;
- return;
- }
- for (long j = 1; j <= m; ++j)
- {
- a[i] = j;
- if (check(i))
- recursion(i+1);
- }
- }
- void process()
- {
- a.resize(n+1, 0);
- recursion(1);
- }
- void view()
- {
- }
- int main()
- {
- openf();
- data();
- process();
- view();
- closef();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment