Codeforces 350E - Wrong Floyd



using namespace std;

const int maxn = 3123;

bool vis[maxn];

int getnod(int n){
    for(int i = 1;i<=n;i++) if(vis[i] == false) return i;
    return -1;
int getlef(int n){
    for(int i = 1;i<=n;i++) if(vis[i]) return i;
    return -1;
vector<pair<int,int> > ans;

bool check(int n,int m){
    int st;
    if((st = getnod(n)) == -1) return false;
    int lef = getlef(n);
    for(int i = 1;i<=n;i++){
        if(i == lef) continue;
        for(int j = i+1 ; j <= n;j++){
            if(j == lef) continue;
            if(m > 0){
    for(int i = 1;i <= n;i++){
        if( i == lef || i == st) continue;
        if( m > 0 && !vis[i]){
    return m == 0;

int main(){
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    int x;
        vis[x] = true;
        for(auto x : ans){
            printf("%d %d\n",x.first,x.second);
    return 0;

codeforces 621B wrong answer 求解


题目rnrnB. Wet Shark and Bishopsrnrntime limit per test:2 secondsrnrnmemory limit per test:256 megabytesrnrninput:standard inputrnrnoutput:standard outputrnrnrnToday, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.rnrnWet Shark thinks that two bishops attack each other if they share the same diagonal. Note, that this is the only criteria, so two bishops may attack each other (according to Wet Shark) even if there is another bishop located between them. Now Wet Shark wants to count the number of pairs of bishops that attack each other.rnrnrnInputrnrnThe first line of the input contains n (1 ≤ n ≤ 200 000) — the number of bishops.rnrnEach of next n lines contains two space separated integers xi and yi (1 ≤ xi, yi ≤ 1000) — the number of row and the number of column where i-th bishop is positioned. It's guaranteed that no two bishops share the same position.rnrnrnOutputrnrnOutput one integer — the number of pairs of bishops which attack each other. rnrnrnSample test(s)rnrnrnrnInputrn5rn1 1rn1 5rn3 3rn5 1rn5 5rnrnrnrnOutputrn6rnrnrnrnInputrn3rn1 1rn2 3rn3 5rnrnrnrnOutputrn0rnrnrnrnNoternrnIn the first sample following pairs of bishops attack each other: (1, 3), (1, 5), (2, 3), (2, 4), (3, 4) and (3, 5). Pairs (1, 2), (1, 4), (2, 5) and (4, 5) do not attack each other because they do not share the same diagonal.rnrnrnrnrn我的代码rn#includern#includern#includern#includern#includern#includern#includernusing namespace std;rnint x[1050],y[1050],n,a[1050][1050];rnbool panduan(int i,int j)rnrn if((i>=1)&&(i<=1000)&&(j>=1)&&(j<=1000))rn return true;rn elsern return false;rnrnint main(void)rnrn long long sum=0;rn int ii,jj,status,j,i,temp_a,temp_b;rn scanf("%d",&n);rn for(i=1;i<=1000;i++)rn for(j=1;j<=1000;j++)rn a[i][j]=0;rn for(i=0;i