QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603201#8940. Piggy Sortucup-team073WA 1ms3760kbC++203.6kb2024-10-01 15:13:102024-10-01 15:13:10

Judging History

你现在查看的是最新测评结果

  • [2024-10-01 15:13:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3760kb
  • [2024-10-01 15:13:10]
  • 提交

answer

#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#define pii std::pair<int,int>
#define pb emplace_back
#define fi first
#define se second
template <class T> 
inline void ckmax(T &a, T b) {
  if(a < b) a = b;
}
template <class T> 
inline void ckmin(T &a, T b) {
  if(a > b) a = b;
}
auto rt_YES = []{puts("YES");};
auto rt_Yes = []{puts("Yes");};
auto rt_NO = []{puts("NO");};
auto rt_No = []{puts("No");};
namespace IO {
#define isdigit(x) (x >= '0' && x <= '9')
  inline char gc() {
    return getchar();
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for(; !isdigit(ch); ch = gc())
      if(ch == '-') sign = 1;
    for(; isdigit(ch); ch = gc())
      x = x * 10 + (ch - '0');
    if(ch == '.')
      for(ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if(sign) x = -x;
  }
  inline void read(char *s) {
    char ch = gc();
    for(; blank(ch); ch = gc());
    for(; !blank(ch); ch = gc())
      *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for(c = gc(); blank(c); c = gc());
  }
  inline void push(const char &c) {
    putchar(c);
  }
  template <class T>
  inline void print(T x) {
    if(x < 0) {
      x = -x;
      push('-');
    }
    static T sta[35];
    T top = 0;
    do {
      sta[top++] = x % 10;
      x /= 10;
    } while(x);
    while(top)
      push(sta[--top] + '0');
  }
  template <class T>
  inline void print(T x, char lastChar) {
    print(x);
    push(lastChar);
  }
}
using namespace IO;

int n,m,a[510][510],s[510],ans[510];
std::multiset<int>mset[510];
struct node{int val,id;}rk[510];
bool cmp(node a,node b){
  if(a.val==b.val)return a.id<b.id;
  return a.val<b.val;
}
void solve(){
  read(n),read(m);
  rep(i,1,m)mset[i].clear(),s[i]=0;
  rep(i,1,m)rep(j,1,n)read(a[i][j]),s[i]+=a[i][j],mset[i].insert(a[i][j]);
  rep(i,2,m)s[i]=(s[i]-s[1])/n;
  rep(i,2,m)debug("%lld ",s[i]);debug("\n");fflush(stdout);
  s[1]=0;
  if(s[2]==0||m==1){rep(i,1,n)print(i,' ');puts("");return;}
  rep(i,1,n){
    for(auto j:mset[2]){
      int flag=1;
      rep(k,3,m){
        if((a[1][i]-j)*s[k]%s[2]){flag=0;break;}
        int p=a[1][i]-(a[1][i]-j)*s[k]/s[2];
        if(mset[k].find(p)==mset[k].end()){flag=0;break;}
      }
      if(flag){
        debug("%lld %lld\n",i,j);fflush(stdout);
        rk[i]={j-a[1][i],i};
        rep(k,3,m){
          int p=a[1][i]-(a[1][i]-j)*s[k]/s[2];
          debug("p %lld\n",p);fflush(stdout);
          auto it=mset[k].find(p);
          mset[k].erase(it);
        }
        auto it=mset[2].find(j);
        mset[2].erase(it);
        break;
      }
    }
    for(auto j:mset[2])debug("%lld ",j);debug("\n");fflush(stdout);
  }
  std::sort(rk+1,rk+n+1,cmp);
  rep(i,1,n)ans[rk[i].id]=i;
  rep(i,1,n)print(ans[i],' ');
  puts("");
}

signed main() {
  clock_t c1 = clock();
#ifdef LOCAL
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
//------------------------------------------------------------------

  int t;read(t);while(t--)solve();

//------------------------------------------------------------------
end:
  std::cerr << "Time : " << clock() - c1 << " ms" << std::endl;
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3636kb

input:

3
2 4
1 2
3 4
5 6
7 8
1 2
1
1
3 4
1 2 3
6 9 9
10 15 17
12 18 21

output:

1 2 
1 
3 1 2 

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3760kb

input:

41
1 2
-19
9531
2 3
11 13
3175 4759
2211 3313
10 19
-54 -25 -19 -18 -1 3 61 63 85 88
-54 753 863 2397 3111 4649 4671 4756 5507 7762
-54 369 479 1245 1575 2345 2367 2452 2819 3922
-54 553 663 1797 2311 3449 3471 3556 4107 5762
-54 87 197 399 447 653 675 760 845 1102
-54 320 430 1098 1379 2051 2073 21...

output:

1 
1 2 
9 10 0 0 0 0 0 0 0 0 
8 10 0 0 0 9 0 0 0 
7 10 0 0 0 9 0 0 0 0 
3 5 10 6 7 4 9 8 2 1 
3 5 10 6 7 4 9 8 
3 1 5 2 6 9 8 7 4 10 
2 3 1 4 
3 2 9 1 4 6 7 5 8 
3 2 9 1 4 6 7 5 8 
4 3 9 2 5 7 8 6 9 
5 4 9 3 6 8 9 7 10 2 
5 4 9 3 6 8 9 7 10 2 
5 4 9 3 6 8 9 7 10 
8 1 2 7 6 9 3 5 4 
9 1 2 7 6 10 3 5 ...

result:

wrong answer 3rd lines differ - expected: '1 2 6 10 5 7 9 4 3 8', found: '9 10 0 0 0 0 0 0 0 0 '