QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#23225 | #1827. Token Game | YaoBIG | WA | 147ms | 4112kb | C++17 | 2.7kb | 2022-03-14 06:01:20 | 2022-04-30 02:36:46 |
Judging History
answer
#include "bits/stdc++.h"
#define rep(i,a,n) for(auto i=a;i<=n;i++)
#define per(i,a,n) for(auto i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define all(A) A.begin(),A.end()
#define sz(A) (int)A.size()
template<class T> inline bool chmax(T &a, T b) {if(a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) {if(b<a) {a=b; return 1;} return 0;}
using namespace std;
string to_string(const string& s) {return '"' + s + '"';}
string to_string(const char* s) {return to_string((string) s);}
template<typename A, typename B> string to_string(pair<A, B> p) {return "(" + to_string(p.FI) + ", " + to_string(p.SE) + ")";}
template<typename A> string to_string(A v)
{
bool first = 1;
string res = "{";
for(const auto &x: v)
{
if (!first) res += ", ";
first = 0;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() {cerr << endl;}
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{
cerr << " " << to_string(H);
debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) if(0) puts("No effect.")
#endif
using ll = long long;
//using LL = __int128;
using pii = pair<int,int>;
using vi = vector<int>;
using db = double;
using ldb = long double;
const int maxn = 300;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
int sg[maxn+5][maxn+5];
int main()
{
rep(i,1,maxn) rep(j,i+2,maxn)
{
vi mark(maxn+1);
rep(k,1,i-1) mark[sg[k][j]] = 1;
rep(k,1,j-1) if(abs(i-k)>1) mark[sg[min(i,k)][max(i,k)]] = 1;
rep(x,0,maxn) if(mark[x]==0) {sg[i][j] = x; break;}
}
int cas; scanf("%d",&cas); while(cas--)
{
int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
if(abs(x1-x2)+abs(y1-y2)<=1) puts("0");
else if(abs(x1-x2)<=1 && abs(y1-y2)<=1) puts("2");
else
{
int sgx = abs(x1-x2)<=1 ? -1 : sg[min(x1,x2)][max(x1,x2)];
int sgy = abs(y1-y2)<=1 ? -1 : sg[min(y1,y2)][max(y1,y2)];
int ans = 0;
auto solve = [&](int sgy,int i,int j) {
if(sgy==-1) ans++;
else
{
static vi mark; mark.assign(maxn+1,0);
rep(k,1,i-1) if(abs(j-k)>1 && sg[k][j]==sgy) ans++;
rep(k,1,j-1) if(abs(i-k)>1 && sg[min(i,k)][max(i,k)]==sgy) ans++;
}
};
solve(sgy,min(x1,x2),max(x1,x2));
solve(sgx,min(y1,y2),max(y1,y2));
printf("%d\n",ans);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 27ms
memory: 4048kb
input:
5 6 6 6 3 6 6 2 2 1 6 3 1 3 6 1 3 6 3 1 5
output:
3 0 1 1 0
result:
ok 5 number(s): "3 0 1 1 0"
Test #2:
score: -100
Wrong Answer
time: 147ms
memory: 4112kb
input:
100000 215 233 28 258 15 243 61 148 172 28 96 37 15 132 62 27 41 186 255 54 145 192 249 263 274 70 185 197 50 101 202 230 256 11 285 19 149 268 163 107 177 201 216 126 65 17 105 263 143 148 2 230 40 128 259 176 183 192 293 169 281 59 240 229 257 157 126 182 161 51 164 14 149 191 227 102 55 14 267 19...
output:
3 2 1 1 1 74 3 3 1 2 3 1 2 1 2 3 3 1 2 1 1 1 1 2 1 1 1 2 2 1 3 1 3 2 1 3 1 1 1 3 4 1 1 3 2 2 2 1 1 1 3 2 2 2 3 1 1 149 1 2 3 1 239 1 1 3 1 3 3 2 2 2 3 3 1 1 2 2 2 2 103 1 3 2 1 2 1 1 2 1 4 1 1 1 3 3 1 1 1 2 2 1 2 1 1 3 2 3 38 1 1 3 61 1 1 1 90 2 2 2 3 2 3 2 1 1 3 3 3 1 2 3 1 2 2 1 1 2 3 2 2 2 1 1 3 ...
result:
wrong answer 2nd numbers differ - expected: '1', found: '2'