QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397983 | #3756. 字典序 | xlwang# | WA | 92ms | 19408kb | C++14 | 1.8kb | 2024-04-24 20:58:23 | 2024-04-24 20:58:24 |
Judging History
answer
#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
int n,m;
const int Maxn=2e3+10;
int a[Maxn][Maxn];
vector<int> vc[Maxn];
int vis[Maxn];
int d[Maxn];
priority_queue<int> q;
vector<int> ans;
inline void work(){
vector<int> ().swap(ans);
while(!q.empty()) q.pop();
fr(i,1,n) fr(j,1,m) a[i][j]=read();
fr(i,1,m) vc[i].clear(),d[i]=0;
fr(i,2,n) vis[i]=0;
fr(j,1,m) fr(i,2,n) if(a[i][j]<a[i-1][j]) ++d[j],vc[i].push_back(j);
fr(i,1,m) if(!d[i]) q.push(-i);
while(!q.empty()){
int x=-q.top();q.pop();ans.push_back(x);
fr(i,2,n) if(a[i][x]>a[i-1][x] && !vis[i]){
vis[i]=1;
for(auto y:vc[i]){
--d[y];if(d[y]==0) q.push(-y);
}
}
}
if(ans.size()!=m){
writeln(-1);
return;
}
for(auto x:ans) writepl(x);puts("");
}
inline void init(){
while(cin>>n>>m) work();
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 92ms
memory: 19408kb
input:
8 3 6 1 2 3 2 2 7 2 2 7 2 2 7 2 2 9 2 2 10 2 2 4 10 2 6 2 3 1 3 4 3 4 3 7 3 7 3 8 7 7 1 3 3 2 6 3 3 1 3 3 2 6 3 3 1 3 3 2 6 3 3 6 3 3 2 1 4 3 6 3 3 2 4 4 3 7 2 4 2 4 10 6 7 3 4 10 4 3 3 4 3 2 3 9 2 4 9 2 4 9 2 4 9 8 10 9 6 6 3 6 10 1 8 2 5 9 6 6 3 6 10 1 9 2 5 5 3 8 6 7 2 1 7 2 10 5 10 8 7 4 7 1 4 8...
output:
2 1 3 1 2 1 2 3 4 5 6 7 1 2 3 7 3 1 2 4 5 6 8 9 10 3 2 1 4 5 1 3 2 4 5 6 7 8 9 1 2 3 4 5 6 1 2 3 4 5 6 2 1 3 4 5 6 6 4 3 5 1 2 7 8 9 10 1 2 1 2 4 6 7 1 3 5 8 1 2 2 1 1 2 3 1 9 4 3 5 1 2 6 7 8 10 1 2 3 1 3 4 2 1 5 6 1 3 4 5 6 7 2 8 9 2 1 3 4 1 2 3 4 6 5 5 1 2 4 3 6 7 8 9 1 2...
result:
wrong answer 255th words differ - expected: '4', found: '1'