Viết checker (tong ami)
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
ifstream inp(argv[1]);
ifstream out(argv[2]);
ifstream ans(argv[3]);
int n, a, b, c, d;
inp >> n;
out >> a >> b;
ans >> c >> d;
if (a + b == c + d) {
cout << a << " + " << b << " = " << c << " + " << d << endl;
return 0; // AC
}
else {
cout << "a + b = " << a + b << " != " << n << endl;
return 1; // WA
}
}
/***********************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn (ll)(105)
ll pos1,length,pos2,i,n,dem,size_b;
ll a[maxn],b[maxn],c[maxn];
int main(){
cin>>n;
for(i=1;i<=n;i++) a[i]=i;
cin>>pos1>>length>>pos2;
for(i=1;i<=n;i++){
if(!(pos1<=i&&i<=pos1+length-1)) b[++dem]=i;
}
size_b=dem;
dem=0;
if(pos2==0){
for(i=pos1;i<=pos1+length-1;i++) c[++dem]=a[i];
for(i=1;i<=size_b;i++) c[++dem]=b[i];
}
else{
for(i=1;i<=pos2;i++) c[++dem]=b[i];
for(i=pos1;i<=pos1+length-1;i++) c[++dem]=a[i];
for(i=pos2+1;i<=size_b;i++) c[++dem]=b[i];
}
for(i=1;i<=dem;i++) a[i]=c[i];
for(i=1;i<=dem;i++) cout<<a[i]<<" ";
}
/*i=pos1;i<=pos1+length-1;i++*/
/*
5
2 2 3
1 2 3 4 5
1 4 5 2 3
*/
using namespace std;
int main(int argc, char** argv) {
ifstream inp(argv[1]);
ifstream out(argv[2]);
ifstream ans(argv[3]);
int n, a, b, c, d;
inp >> n;
out >> a >> b;
ans >> c >> d;
if (a + b == c + d) {
cout << a << " + " << b << " = " << c << " + " << d << endl;
return 0; // AC
}
else {
cout << "a + b = " << a + b << " != " << n << endl;
return 1; // WA
}
}
/***********************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn (ll)(105)
ll pos1,length,pos2,i,n,dem,size_b;
ll a[maxn],b[maxn],c[maxn];
int main(){
cin>>n;
for(i=1;i<=n;i++) a[i]=i;
cin>>pos1>>length>>pos2;
for(i=1;i<=n;i++){
if(!(pos1<=i&&i<=pos1+length-1)) b[++dem]=i;
}
size_b=dem;
dem=0;
if(pos2==0){
for(i=pos1;i<=pos1+length-1;i++) c[++dem]=a[i];
for(i=1;i<=size_b;i++) c[++dem]=b[i];
}
else{
for(i=1;i<=pos2;i++) c[++dem]=b[i];
for(i=pos1;i<=pos1+length-1;i++) c[++dem]=a[i];
for(i=pos2+1;i<=size_b;i++) c[++dem]=b[i];
}
for(i=1;i<=dem;i++) a[i]=c[i];
for(i=1;i<=dem;i++) cout<<a[i]<<" ";
}
/*i=pos1;i<=pos1+length-1;i++*/
/*
5
2 2 3
1 2 3 4 5
1 4 5 2 3
*/
Nhận xét
Đăng nhận xét