You are given a correct solution of the sudoku puzzle. If you don't know what is the sudoku, you can read about it here.
The picture showing the correct sudoku solution:
Blocks are bordered with bold black color.
Your task is to change at most 99 elements of this field (i.e. choose some 1≤i,j≤91≤i,j≤9 and change the number at the position (i,j)(i,j) to any other number) to make it anti-sudoku. The anti-sudoku is the 9×99×9 field, in which:
- Each row contains at least two equal elements;
- each column contains at least two equal elements;
- each 3×33×3 block (you can read what is the block in the link above) contains at least two equal elements.
It is guaranteed that the answer exists.
You have to answer tt independent test cases.
Input
The first line of the input contains one integer tt (1≤t≤1041≤t≤104) — the number of test cases. Then tt test cases follow.
Each test case consists of 99 lines, each line consists of 99 characters from 11 to 99 without any whitespaces — the correct solution of the sudoku puzzle.
Output
For each test case, print the answer — the initial field with at most 99 changed elements so that the obtained field is anti-sudoku. If there are several solutions, you can print any. It is guaranteed that the answer exists.
Example
1 154873296 386592714 729641835 863725149 975314628 412968357 631457982 598236471 247189563
154873396 336592714 729645835 863725145 979314628 412958357 631457992 998236471 247789563
ACcode#1
#include<bits/stdc++.h> using namespace std; const int N = 2e5+7; int cnt[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while (t--) { for (int i=0; i<9; i++) { string s; cin>>s; for (char &c: s) if (c == '1')//随便一个1~9的数字变成1~9的另一个数字即可 c = '2'; cout<<s<<endl; } } }
ACcode#2
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll inf = 1e18; const int mod = 1000000007; const int mx = 100; //check the limits, dummy typedef pair<int, int> pa; const double PI = acos(-1); ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } #define swa(a,b) a^=b^=a^=b #define re(i,a,b) for(int i=(a),_=(b);i<_;i++) #define rb(i,a,b) for(int i=(b),_=(a);i>=_;i--) #define clr(a) memset(a, 0, sizeof(a)) #define lowbit(x) ((x)&(x-1)) #define mkp make_pair void sc(int& x) { scanf("%d", &x); }void sc(int64_t& x) { scanf("%lld", &x); }void sc(double& x) { scanf("%lf", &x); }void sc(char& x) { scanf(" %c", &x); }void sc(char* x) { scanf("%s", x); } ll m, n,t,x,k,ans=0,sum=0; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { vector<string> s(9); for (int i = 0; i < 9; i++) { cin >> s[i]; } vector<int> a = { 0, 4, 8, 1, 5, 6, 2, 3, 7 }; for (int i = 0; i < 9; i++) { int j = a[i]; s[i][j] = (s[i][j] == '9' ? '1' : s[i][j] + 1); } for (int i = 0; i < 9; i++) { cout << s[i] << '\n'; } } }
ACcode#3
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int t; scanf("%d",&t); vector<array<int,2>> v; for(int i=0;i<3;i++) { int r=3*i; int c=i; for(int j=0;j<3;j++) v.push_back({r+j,c+3*j}); } while(t--) { char s[9][10]; for(int o=0;o<9;o++) scanf("%s",s[o]); for(auto [a,b]:v) { if(s[a][b]=='1') s[a][b]='2'; else s[a][b]='1'; } for(int o=0;o<9;o++) printf("%s\n",s[o]); } return 0; }
ACcode#4
#include<bits/stdc++.h> #define MAXN 100005 #define INF 1000000000 #define MOD 1000000007 #define F first #define S second using namespace std; typedef long long ll; typedef pair<int,int> P; int t,n,a[MAXN]; char mp[15][15]; bool valid[10]; int main() { scanf("%d",&t); while(t--) { for(int i=0;i<9;i++) scanf("%s",mp[i]); int tot=0,j=0; for(int i=0;i<9;i++) { if(i%3==0) { j=tot; tot++; } else j+=3; if(mp[i][j]=='1') mp[i][j]='2'; else mp[i][j]='1'; } for(int i=0;i<9;i++) printf("%s\n",mp[i]); } return 0; }